-
January 20th, 2010, 10:06 AM
#1
"relocation R_X86_64_32 against `.bss' can not be used when making a shared..." error
Hi All,
I am getting "relocation R_X86_64_32 against `.bss' can not be used when making a shared object; recompile with -fPIC" error when compiling a shared object with optimization option -O2 enabled using GNU GCC:
First, I compile a static library, which is used by the shared object, as follows:
Code:
g++ -g -O2 -c common/src/packet-class-registry.cc
ar -cvq libclassreg.a common/src/packet-class-registry.o
Below is how I compile the shared object, which uses libclassreg.a:
Code:
g++ -g -O2 -fPIC -c packet-v4.cc -o packet-v4.o
gcc -shared -Wl,-soname,libv4.so.1 -o libv4.so.1.0 packet-v4.o -Lcommon/lib -Lconf/configLib/lib -lclassreg -lNsConf
/usr/bin/ld: common/lib/libclassreg.a(packet-class-registry.o): relocation R_X86_64_32 against `.bss' can not be used when making a shared object; recompile with -fPIC
common/lib/libclassreg.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make: *** [libv4.so] Error 1
Is this a problem regarding the order of compiler options ? (-O2 appears before -fPIC)
Or is it something else ?
Thanks.
-
January 20th, 2010, 10:48 AM
#2
Re: "relocation R_X86_64_32 against `.bss' can not be used when making a shared..." e
1. Maybe it is rather packet-class-registry.cc that needs to be compiled with -fPIC
2. I have used g++ for compiling and also for linking. I am not sure gcc and g++ are working well together all the time.
3. I am puzzled by the commas in the command line.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|