2 chenxiao ji chenxiao_ji 于 2014.07.26 22:34 提问

Linux下将静态库编译成动态库的问题

使用JNI技术时,需要将第三方提供的静态库编译成动态库,在编译过程中遇到问题,使用gcc进行编译链接:
gcc -I/home/jichenxiao/java/jdk1.8.0_11/include -I/home/jichenxiao/java/jdk1.8.0_11/include/linux -fPIC -shared -o libAir.so AirConditioner.c -L. -Wl,--whole-archive -lBLNetwork-linux-64 -Wl,--no-whole-archive -lpthread -lrt -lm
其中/home/jichenxiao/java/jdk1.8.0_11/include和/home/jichenxiao/java/jdk1.8.0_11/include/linux为jni.h和jni_md.h的路径,libAir.so为输出的动态库,AirConditioner.c为要一起编译的c程序,-lBLNetwork-linux-64为要编译成动态库的静态库文件libBLNetwork-linux-64.a。编译时报的错误为:
/usr/bin/ld: ./libBLNetwork-linux-64.a(aes.o): relocation R_X86_64_32S against `.bss' can not be used when making a shared object; recompile with -fPIC
./libBLNetwork-linux-64.a(aes.o): error adding symbols: Bad value
collect2: error: ld returned 1 exit status
我不懂编译原理,请教大家,希望大家能给出解决方案,谢谢!

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!