studio ndk c++ c android-ndk gdc bionic

c++ - studio - android ndk location



¿A qué biblioteca se refiere la opción ld-lrt(Bionic libc)? (3)

¿Qué significa esta opción para ld?

-lrt

Sé que hasta cierto punto significa que ld está buscando la biblioteca con extensiones en tiempo real, pero después de buscar extensamente, no pude encontrar una definición exacta (o a qué biblioteca) se refiere.

Con Bionic (android) libc, el NDK de Android detalla que esto (junto con pthreads) se ha integrado.

Lo pregunto porque parece ser implícito (es decir, cuando invoco al compilador, un gdc compilado a medida, directamente, recibo un mensaje que dice que ld no puede encontrar -lrt)

EDITAR

Desde el panorama biónico

La biblioteca C de Bionic viene con su propia implementación pthread incluida. Esto es diferente de otras bibliotecas C históricas que:

- place it in an external library (-lpthread) - play linker tricks with weak symbols at dynamic link time

El soporte para funciones en tiempo real (también conocido como -lrt) también se incluye en la biblioteca C.

El problema es que collect2 está pasando la opción -lrt (y también -lpthreads) a ld.

dan@devbox:~/projects/gdc_test/jni/src$ $DC gdc_test.d -v -mthumb Using built-in specs. Target: arm-linux-androideabi Configured with: /arm/ndk-git/src/build/../gcc/gcc-4.4.3/configure --prefix=/arm/ndk-git/ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86 --target=arm-linux-androideabi --host=x86_64-linux-gnu --build=x86_64-linux-gnu --with-gnu-as --with-gnu-ld --enable-languages=c,c++ --with-gmp=/arm/ndk-git/build_run/temp-install --with-mpfr=/arm/ndk-git/build_run/temp-install --disable-libssp --enable-threads --disable-nls --disable-libmudflap --disable-libgomp --disable-libstdc__-v3 --disable-sjlj-exceptions --disable-shared --disable-tls --enable-languages=c,d,c++ --enable-lto --with-float=soft --with-fpu=vfp --with-arch=armv5te --enable-target-optspace --enable-shared--prefix=/arm/ndk-git/ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86 --enable-initfini-array --disable-nls --prefix=/arm/ndk-git/ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86 --with-sysroot=/arm/ndk-git/ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/sysroot --with-binutils-version=2.19 --with-mpfr-version=2.4.1 --with-gmp-version=4.2.4 --with-gcc-version=4.4.3 --with-gdb-version=6.6 --with-arch=armv5te --enable-libstdc__-v3 --disable-werrors --enable-languages=c,d,c++ --enable-shared --enable-multilib --disable-threads --program-transform-name=''s,^,arm-linux-androideabi-,'' Thread model: single gcc version 4.4.3 20100121 (gdc hg, using dmd 1.067) (GCC) COLLECT_GCC_OPTIONS=''-v'' ''-mthumb'' ''-shared-libgcc'' ''-pthread'' ''-march=armv5te'' ''-mfloat-abi=soft'' ''-mfpu=vfp'' /home/dan/projects/arm-linux-androideabi-4.4.3/bin/../libexec/gcc/arm-linux-androideabi/4.4.3/cc1d gdc_test.d -mbionic -fpic -quiet -dumpbase gdc_test.d -mthumb -march=armv5te -mfloat-abi=soft -mfpu=vfp -auxbase gdc_test -version -imultilib thumb -iprefix /home/dan/projects/arm-linux-androideabi-4.4.3/bin/../lib/gcc/arm-linux-androideabi/4.4.3/ -isysroot /home/dan/projects/arm-linux-androideabi-4.4.3/bin/../sysroot -fmultilib-dir=thumb -o /tmp/cc2yu97y.s GNU D (GCC) version 4.4.3 20100121 (gdc hg, using dmd 1.067) (arm-linux-androideabi) compiled by GNU C version 4.5.2, GMP version 4.2.4, MPFR version 2.4.1. GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 GNU D (GCC) version 4.4.3 20100121 (gdc hg, using dmd 1.067) (arm-linux-androideabi) compiled by GNU C version 4.5.2, GMP version 4.2.4, MPFR version 2.4.1. GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 COLLECT_GCC_OPTIONS=''-v'' ''-mthumb'' ''-shared-libgcc'' ''-pthread'' ''-march=armv5te'' ''-mfloat-abi=soft'' ''-mfpu=vfp'' /home/dan/projects/arm-linux-androideabi-4.4.3/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/as -v -march=armv5te -mfloat-abi=soft -mfpu=vfp -meabi=5 -o /tmp/ccuFGEfj.o /tmp/cc2yu97y.s GNU assembler version 2.19 (arm-linux-androideabi) using BFD version (GNU Binutils) 2.19 COMPILER_PATH=/home/dan/projects/arm-linux-androideabi-4.4.3/bin/../libexec/gcc/arm-linux-androideabi/4.4.3/:/home/dan/projects/arm-linux-androideabi-4.4.3/bin/../libexec/gcc/:/home/dan/projects/arm-linux-androideabi-4.4.3/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ LIBRARY_PATH=/home/dan/projects/arm-linux-androideabi-4.4.3/bin/../lib/gcc/arm-linux-androideabi/4.4.3/thumb/:/home/dan/projects/arm-linux-androideabi-4.4.3/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/lib/thumb/:/home/dan/projects/arm-linux-androideabi-4.4.3/bin/../lib/gcc/arm-linux-androideabi/4.4.3/:/home/dan/projects/arm-linux-androideabi-4.4.3/bin/../lib/gcc/:/home/dan/projects/arm-linux-androideabi-4.4.3/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/lib/:/home/dan/projects/arm-linux-androideabi-4.4.3/bin/../sysroot/usr/lib/ COLLECT_GCC_OPTIONS=''-v'' ''-mthumb'' ''-shared-libgcc'' ''-pthread'' ''-march=armv5te'' ''-mfloat-abi=soft'' ''-mfpu=vfp'' /home/dan/projects/arm-linux-androideabi-4.4.3/bin/../libexec/gcc/arm-linux-androideabi/4.4.3/collect2 --sysroot=/home/dan/projects/arm-linux-androideabi-4.4.3/bin/../sysroot --eh-frame-hdr -dynamic-linker /system/bin/linker -X -m armelf_linux_eabi /home/dan/projects/arm-linux-androideabi-4.4.3/bin/../sysroot/usr/lib/crtbegin_dynamic.o -L/home/dan/projects/arm-linux-androideabi-4.4.3/bin/../lib/gcc/arm-linux-androideabi/4.4.3/thumb -L/home/dan/projects/arm-linux-androideabi-4.4.3/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/lib/thumb -L/home/dan/projects/arm-linux-androideabi-4.4.3/bin/../lib/gcc/arm-linux-androideabi/4.4.3 -L/home/dan/projects/arm-linux-androideabi-4.4.3/bin/../lib/gcc -L/home/dan/projects/arm-linux-androideabi-4.4.3/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/lib -L/home/dan/projects/arm-linux-androideabi-4.4.3/bin/../sysroot/usr/lib /tmp/ccuFGEfj.o -lgphobos -lm -lrt -lgcc_s -lgcc -lpthread -lc -ldl -lgcc_s -lgcc /home/dan/projects/arm-linux-androideabi-4.4.3/bin/../sysroot/usr/lib/crtend_android.o /home/dan/projects/arm-linux-androideabi-4.4.3/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: cannot find -lrt collect2: ld returned 1 exit status

¿Hay una manera de anular este comportamiento?


Cuando ves -lsomething , el nombre de la biblioteca es libsomething . Haciendo un man librt dice lo siguiente:

NAME librt, libposix4 - POSIX.1b Realtime Extensions library SYNOPSIS cc [ flag... ] file... -lrt [ library... ] DESCRIPTION Functions in this library provide most of the interfaces specified by the POSIX.1b Realtime Extension. See stan- dards(5). Specifically, this includes the interfaces defined under the Asynchronous I/O, Message Passing, Process Scheduling, Realtime Signals Extension, Semaphores, Shared Memory Objects, Synchronized I/O, and Timers options. The interfaces defined under the Memory Mapped Files, Process Memory Locking, and Range Memory Locking options are pro- vided in libc(3LIB) See the man pages for the individual interfaces in section 3RT for information on required headers. The name libposix4 is maintained for backward compatibility and should be avoided. librt is the preferred name for this library.


Respondiendo a mi propia pregunta: estaba codificado en gdc / d / d-spec.c


-l es la bandera utilizada para vincular una biblioteca a su ejecutable final. En este caso, la biblioteca en cuestión es librt.a (o librt.so o librt.dylib , dependiendo de su sistema). librt es la biblioteca de extensiones en tiempo real.