我正在将一些共享对象文件编译到archive.a中:
$g++ -c -Iinclude/ -fPIC -O0 -o object1.o source1.cpp $g++ -c -Iinclude/ -fPIC -O0 -o object2.o source2.cpp $ar rvs archive.a object1.o object2.o r - object1.o r - object2.o
到现在为止还挺好.最终的archive.a具有一些KB的大小.带有nm的转储表示相应的对象文件包含在文件中.
现在我想将这些档案中的几个编译成一个共享对象文件.
g++ -g -O0 -Iinclude/ -I/usr/include/somelibrary -shared -o libLibrary.so archive1.a archive2.a
$nm -D libLibrary.so w _Jv_RegisterClasses 0000000000201010 A __bss_start w __cxa_finalize w __gmon_start__ 0000000000201010 A _edata 0000000000201020 A _end 0000000000000578 T _fini 0000000000000430 T _init
任何想法我在做错什么?
编辑:
当我尝试切换-Wl,– 整个档案,以下情况发生:
/usr/lib/x86_64-linux-gnu/libc_nonshared.a(elf-init.oS): In function `__libc_csu_init': (.text+0xd): undefined reference to `__init_array_end' /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libc_nonshared.a(elf-init.oS): relocation R_X86_64_PC32 against undefined hidden symbol `__init_array_end' can not be used when making a shared object /usr/bin/ld: final link Failed: Bad value collect2: ld returned 1 exit status make: *** [libKeynect.so] Error 1