Boost logo

Boost Users :

Subject: [Boost-users] building Boost with -fPIC on x86_64 linux box
From: Francois Mauger (mauger_at_[hidden])
Date: 2009-04-07 11:50:57


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_at_[hidden]
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

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net