x86_64 needs -fPIC issue, anyone successful?

I'm trying to build a library (librets) that links against boost libraries in order to build a shared library (as part of a SWIG based python extension). The target machine, as well as all of my development machines at the moment, are the x86_64 architecture. I've done most of my work on an ubuntu 9.04 box. I've tried with the boost packages available from the ubuntu repositores, and I have also, in case those packages were miss-built, successfully built (and tried the examples, successfully) boost 1.43.0 from source, getting no errors from ./bjam install . In either case, I wind up with the following error when trying to build librets: /usr/bin/ld: /home/f/Desktop/rets/lib/libboost_system.a(error_code.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC Googling around, this seems to be a problem only seen on x86_64 machines. (Why one doesn't need to make position independent code for the 32 bit machines, if that is in fact true, is beyond me.) So, I'm wondering if someone else with this issue has already figured out how to get around it. Or, if not, can someone tell me how to tell the bjam stuff to apply -fPIC so that I can try that. (I'm an old timer. If it were make based, I could hack it myself, but I'm hesitant to learn all about the boost build system for what is for me a side task.) Or if someone knows that the -fPIC won't help, or has alternate suggestions, please let me know. TIA, Bill

Bill Freeman wrote:
I'm trying to build a library (librets) that links against boost libraries in order to build a shared library (as part of a SWIG based python extension).
The target machine, as well as all of my development machines at the moment, are the x86_64 architecture. I've done most of my work on an ubuntu 9.04 box.
I've tried with the boost packages available from the ubuntu repositores, and I have also, in case those packages were miss-built, successfully built (and tried the examples, successfully) boost 1.43.0 from source, getting no errors from ./bjam install .
In either case, I wind up with the following error when trying to build librets:
/usr/bin/ld: /home/f/Desktop/rets/lib/libboost_system.a(error_code.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
Googling around, this seems to be a problem only seen on x86_64 machines. (Why one doesn't need to make position independent code for the 32 bit machines, if that is in fact true, is beyond me.)
So, I'm wondering if someone else with this issue has already figured out how to get around it.
Or, if not, can someone tell me how to tell the bjam stuff to apply -fPIC so that I can try that. (I'm an old timer. If it were make based, I could hack it myself, but I'm hesitant to learn all about the boost build system for what is for me a side task.)
Or if someone knows that the -fPIC won't help, or has alternate suggestions, please let me know.
TIA, Bill
You should have a libboost_system.so to link against (which should have, and probably was, built with -fpic). Either: 1) You don't have libboost_system.so where linker is looking or 2) Usually these are setup as symlinks, libboost_system.so -> libboost_system.so.x.y.z You could be missing the symlink, or it could point to the wrong place.

On Fri, 2010-08-06 at 01:03 +0300, Bill Freeman wrote:
Or, if not, can someone tell me how to tell the bjam stuff to apply -fPIC so that I can try that. (I'm an old timer. If it were make based, I could hack it myself, but I'm hesitant to learn all about the boost build system for what is for me a side task.)
bjam [your options] cxxflags=-fPIC At work we use for boost 1.41 bjam -a --layout=system install link=static variant=release \ threading=multi cxxflags=-fPIC --> Mika Heiskanen

Thanks, Mika. Building as we speak.
Bill
----- Original Message -----
From: "Mika Heiskanen"
Or, if not, can someone tell me how to tell the bjam stuff to apply -fPIC so that I can try that. (I'm an old timer. If it were make based, I could hack it myself, but I'm hesitant to learn all about the boost build system for what is for me a side task.)
bjam [your options] cxxflags=-fPIC At work we use for boost 1.41 bjam -a --layout=system install link=static variant=release \ threading=multi cxxflags=-fPIC --> Mika Heiskanen _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

And this works.
Now I'm getting far enough to know that I have the same
hoop to jump through for libexpat, and who knows how many
others. I guess it's time to look at that librets makefile
in detail.
Bill
----- Original Message -----
From: "Bill Freeman"
Or, if not, can someone tell me how to tell the bjam stuff to apply -fPIC so that I can try that. (I'm an old timer. If it were make based, I could hack it myself, but I'm hesitant to learn all about the boost build system for what is for me a side task.)
bjam [your options] cxxflags=-fPIC At work we use for boost 1.41 bjam -a --layout=system install link=static variant=release \ threading=multi cxxflags=-fPIC --> Mika Heiskanen _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (3)
-
Bill Freeman
-
Mika Heiskanen
-
Neal Becker