I compiled according to the official thrift tutorial, and the command is as follows:
./configure --pre=/usr/local/demo/ --with-ruby=no --with-python=no --with-java=no --with-go=no --with-perl=no --with-php=no --with-csharp=no --with-erlang=no --with-lua=no --with-nodejs=no --with-rs=no --with-py3=no CXXFLAGS='-Wno-error' CFLAGS=-fPIE
make
make install
I got thrift's header files and static libraries in /usr/local/demo. Then I copied the directory to another machine The test program was compiled, and finally the following error was obtained. If you test directly on the original machine, there is no problem.
I have two questions I'd like your help with
- Why is this
- How to solve this error, because my other machine environment lacks the dependency of compiling thrift, so I need this way of porting The compiled code looks and error like this
Compile command:
g++ -o server HelloService.cpp hello_constants.cpp hello_types.cpp server.cpp -
I/usr/local/demo/include /usr/local/demo/lib/libthrift.a -lpthread
Error:
/usr/bin/ld: /usr/local/demo/lib/libthrift.a(TApplicationException.o): relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /usr/local/demo/lib/libthrift.a(TOutput.o): relocation R_X86_64_32S against symbol `_ZN6apache6thrift7TOutput16errorTimeWrapperEPKc' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /usr/local/demo/lib/libthrift.a(TConcurrentClientSyncInfo.o): relocation R_X86_64_32 against symbol `__pthread_key_create@@GLIBC_2.2.5' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /usr/local/demo/lib/libthrift.a(TProtocol.o): relocation R_X86_64_32 against symbol `__pthread_key_create@@GLIBC_2.2.5' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /usr/local/demo/lib/libthrift.a(TTransportException.o): relocation R_X86_64_32S against `.rodata' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /usr/local/demo/lib/libthrift.a(TServerSocket.o): relocation R_X86_64_32 against symbol `__pthread_key_create@@GLIBC_2.2.5' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /usr/local/demo/lib/libthrift.a(TBufferTransports.o): relocation R_X86_64_32 against symbol `__pthread_key_create@@GLIBC_2.2.5' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /usr/local/demo/lib/libthrift.a(SocketCommon.o): relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /usr/local/demo/lib/libthrift.a(TServerFramework.o): relocation R_X86_64_32 against symbol `__pthread_key_create@@GLIBC_2.2.5' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /usr/local/demo/lib/libthrift.a(TSimpleServer.o): relocation R_X86_64_32 against symbol `__pthread_key_create@@GLIBC_2.2.5' can not be used when making a PIE object; recompile with -fPIC