我已经静态编译了OpenSSL库。我希望能够将OpenSSL库与MyModule
一起静态编译。我使用Makefile来完成同样的操作。
LDFLAGS = $(LD_SHARED_FLAGS) -fPIC -static -lssl -lcrypto
在根目录的 Makefile 中,
LD_SHARED_FLAGS
的设置是与共享库相关的。LD_SHARED_FLAGS = -z text
当我运行make命令时,出现以下错误:
g++ -shared -L../../lib -z text -fPIC -static -lssl -lcrypto -o libMyModule.so debug_utils.o MyModule.o labels.o -L/path_to_openssl/lib -lssl -lcrypto -lc
/usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/4.8.5/crtbeginT.o: relocation R_X86_64_32 against `__TMC_END__' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/crtbeginT.o: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
make: *** [libMyModule.so] Error 1
我是否使用了正确的标志进行静态编译?
如何解决这个错误?
-fPIC
重新编译”? - Toby Speight