building Boost with -fPIC on x86_64 linux box

Hi boosters, He is my problem: I have a AMD 64 Linux box with boost installed on it, particularly with the Boost.Python component. Boost version is 1.34.1 (an old one but the same problem occurs with new 1.38.0 as explained below). also gcc version is 3.4.6. I use the standard: ./configure --with-xxxx; make; make install; sequence to build/install the libs. Unfortunately I cannot figure out if the -fPIC is activated while compiling the code... and I don't know how to check the PIC status from the resulting .so files (it is possible and does it make sense? I'm not an expert with this concept). I only know that if I missed the -fPIC flag on this system, I have linker errors. Next step, I have my own 'datatools' library with some classes using Boost stuff. I use plain makefiles for it and I garantee the -fPIC flags is activated to generated my 'libdatatools.so' shared library. Finally, I try to build a Boost.Python wrapper for my classes, trying to link against the 'libdatatools.so' file and 'libboost-xxxx.so' stuff. [Note this procedure works perfectly under 32 bits ubuntu system with gcc 4 and boost 1.34.1] Unfortunately I get this nasty well known error:
g++ datatools.cc ... -I.../sw/boost/install-1_38_0-Linux-x86_64-gcc34/include/boost-1_38 -I/usr/local/include/python2.5 -fno-strict-aliasing -DN DEBUG -g -O3 -Wall -I.../sw/datatools/pro/include -I.-shared -fPIC -O -DBOOST_PYTHON_DYNAMIC_LIB -L../Linux-x86_64/lib -ldatatools -lboost_iostreams-gcc34-mt -lboost_filesystem-gcc34-mt -fPIC -L.../sw/boost/install-1_38_0-Linux-x86_64-gcc34/lib -lboost_python-gcc34-mt -lboost_serialization-gcc34-mt -L/usr/local/lib/python2.5/config -lpthread -ldl -lutil -lpython2.5 -lm -o datatools.so
/usr/bin/ld: /usr/local/lib/python2.5/config/libpython2.5.a(abstract.o): relocat ion R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC /usr/local/lib/python2.5/config/libpython2.5.a: could not read symbols: Bad value collect2: ld returned 1 exit status make: *** [datatools.so] Error 1 <<< So what is the problem? I used -fPIC for my classes and I used -fPIC during the Boost-Python wrapping procedure. Does it mean the Boost library itself has not been compiled with -fPIC despite the fact that it is recommended/mandatory with 64 bits architecture. Or does it mean there is something wrong with 'libpython2.5.a' which is provided by the sysadmin and out of my privilege scope? It seems this kind of issue has already been addressed before but scanning the list archives left me rather confused with no clear solution/hint. I tried to enforce the -fPIC flags adding the following line in user-config.jam with boost 1.38.0:
using gcc : : : <cxxflags>-fPIC ; <<< But it did not help...
I'd really appreciate any hints about this issue. Thanks a lot. regards frc -- François Mauger Département de Physique - Université de Caen Basse-Normandie courriel/e-mail: mauger@lpccaen.in2p3.fr tél./phone: 02 31 45 25 12 / (+33) 2 31 45 25 12 fax: 02 31 45 25 49 / (+33) 2 31 45 25 49 Adresse/address: Laboratoire de Physique Corpusculaire de Caen (UMR 6534) ENSICAEN 6, Boulevard du Marechal Juin 14050 CAEN Cedex FRANCE

Am 07.04.2009 17:50, Francois Mauger schrieb:
I use the standard: ./configure --with-xxxx; make; make install; sequence to build/install the libs. Unfortunately I cannot figure out if the -fPIC is activated while compiling the code...
If using bjam directly for building, cf. http://www.boost.org/doc/libs/1_38_0/more/getting_started/unix-variants.html... you could add then "-d+2" to bjam: CONF+=" -d+2" # Show commands as they are executed CONF+=" -q" # Stop at first error #CONF+=" --debug-configuration" # Diagnose configuration #CONF+=" --debug-building" # Report which targets are built # with what properties (see bjam --help)

Francois Mauger wrote:
Hi boosters,
He is my problem: I have a AMD 64 Linux box with boost installed on it, particularly with the Boost.Python component. Boost version is 1.34.1 (an old one but the same problem occurs with new 1.38.0 as explained below). also gcc version is 3.4.6. ... /usr/bin/ld: /usr/local/lib/python2.5/config/libpython2.5.a(abstract.o): relocat ion R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
It does not seem like the problem has anything to do with Boost.
Or does it mean there is something wrong with 'libpython2.5.a' which is provided by the sysadmin and out of my privilege scope?
Yes. For whatever reason, you have or link to static python library, which, understandably, is not built with -fPIC. - Volodya

Francois Mauger wrote:
I use the standard: ./configure --with-xxxx; make; make install; sequence to build/install the libs. Unfortunately I cannot figure out if the -fPIC is activated while compiling the code... and I don't know how to check the PIC status from the resulting .so files (it is possible and does it make sense? I'm not an expert with this concept). I only know that if I missed the -fPIC flag on this system, I have linker errors.
This is what we did in our boost 1.36 RPM spec file. Probably not the best way to do this, but it worked: %build ./configure --prefix=%{_prefix} --libdir=%{_libdir} cat Makefile | sed -e 's/BJAM_CONFIG=/BJAM_CONFIG=--layout=system --build-type=complete cxxflags=-fPIC/' > Makefile.new mv Makefile.new Makefile make all --> Mika Heiskanen

Thanks to all for the hints, Following Vladimir's comment, I'll ask my sysadmin to build the libpython2.5.so missing file... We will see if this solve the problem.
Mika Heiskanen a écrit :
This is what we did in our boost 1.36 RPM spec file. Probably not the best way to do this, but it worked:
%build ./configure --prefix=%{_prefix} --libdir=%{_libdir} cat Makefile | sed -e 's/BJAM_CONFIG=/BJAM_CONFIG=--layout=system --build-type=complete cxxflags=-fPIC/' > Makefile.new mv Makefile.new Makefile make all
Ok this was my next step. I will try if attempt above fails! thanks again. frc -- François Mauger Département de Physique - Université de Caen Basse-Normandie courriel/e-mail: mauger@lpccaen.in2p3.fr tél./phone: 02 31 45 25 12 / (+33) 2 31 45 25 12 fax: 02 31 45 25 49 / (+33) 2 31 45 25 49 Adresse/address: Laboratoire de Physique Corpusculaire de Caen (UMR 6534) ENSICAEN 6, Boulevard du Marechal Juin 14050 CAEN Cedex FRANCE
participants (4)
-
Carsten Raas
-
Francois Mauger
-
Mika Heiskanen
-
Vladimir Prus