automake
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: R_X86_64_32S error building a shared library


From: Adam Nielsen
Subject: Re: R_X86_64_32S error building a shared library
Date: Mon, 26 Jan 2009 13:07:38 +1000
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-GB; rv:1.8.1.18) Gecko/20081215 Thunderbird/2.0.0.18 Mnenhy/0.7.5.0

I have Boost installed on my system as a shared library, so I don't understand why libtool/gcc won't link to it.

Hmm okay, I think I've just discovered why - it seems my local installation of Boost was compiled without the -fPIC flag, as I have problems even with trivial compiles, without using automake/libtool:

$ g++ -fPIC -c -o main.o main.cpp -I/usr/include/boost-1_37/ && g++ -fPIC -o test.so main.o -shared -lboost_system-mt-1_37 -lboost_filesystem-mt-1_37

/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/../../../../lib64/libboost_system-mt-1_37.a(error_code.o): relocation R_X86_64_32S against `a local symbol' can not be used when making a shared object; recompile with -fPIC /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/../../../../lib64/libboost_system-mt-1_37.a: could not read symbols: Bad value
collect2: ld returned 1 exit status

I think it must have been the way Boost was compiled, because I get the same error even when I don't link to any libraries:

$ g++ -c -o main.o main.cpp -I/usr/include/boost-1_37/ && g++ -o test.so main.o -shared

/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/../../../../x86_64-pc-linux-gnu/bin/ld: main.o: relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
main.o: could not read symbols: Bad value
collect2: ld returned 1 exit status

But if I add -fPIC in that case, it works:

$ g++ -fPIC -c -o main.o main.cpp -I/usr/include/boost-1_37/ && g++ -o test.so main.o -shared

Given that I've used -fPIC in the first command above, it would seem that my local installation of Boost was compiled without -fPIC, so it looks like all I need to do is figure out how to do that and everything should work...

Thanks for all your help!

Cheers,
Adam.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]