小编Sup*_*dra的帖子

Linux下使用g++进行静态编译

我静态编译了 OpenSSL 库。我想MyModule使用 OpenSSL 库进行静态编译。我正在使用 Makefile 来执行相同的操作

LDFLAGS      = $(LD_SHARED_FLAGS) -fPIC -static -lssl -lcrypto
Run Code Online (Sandbox Code Playgroud)

LD_SHARED_FLAGS在根Makefile中有

LD_SHARED_FLAGS     = -z text
Run Code Online (Sandbox Code Playgroud)

当我运行 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
Run Code Online (Sandbox Code Playgroud)
/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
Run Code Online (Sandbox Code Playgroud)

我是否使用了正确的静态编译标志? …

c++ linux openssl g++

4
推荐指数
1
解决办法
4502
查看次数

标签 统计

c++ ×1

g++ ×1

linux ×1

openssl ×1