Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Problem building python 2.7 with --enable-shared

Reply
Thread Tools

Problem building python 2.7 with --enable-shared

 
 
Marten Lehmann
Guest
Posts: n/a
 
      09-16-2010
Hello,

I've build python 2.7 successfully by just calling configure, make and
make install. But to use python within PostgreSQL, I need to built
python with --enable-shared.

I tried to do so (configure --enable-shared), but I see these lines
several times in the log (but compiling continues):

/usr/bin/ld: /test/python/lib/libpython2.7.a(abstract.o): relocation
R_X86_64_32 against `a local symbol' can not be used when making a
shared object; recompile with -fPIC
/test/python/lib/libpython2.7.a: could not read symbols: Bad value
collect2: ld returned 1 exit status

Later, the compiling process ends completely:

PYTHONPATH=/var/tmp/vrmd-python2-root/test/python/lib/python2.7
LD_LIBRARY_PATH=/usr/src/redhat/BUILD/Python-2.7: \
./python -Wi -tt
/var/tmp/vrmd-python2-root/test/python/lib/python2.7/compileall.py \
-d /test/python/lib/python2.7 -f \
-x
'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \
/var/tmp/vrmd-python2-root/test/python/lib/python2.7
Traceback (most recent call last):
File
"/var/tmp/vrmd-python2-root/test/python/lib/python2.7/compileall.py",
line 17, in <module>
import struct
File
"/var/tmp/vrmd-python2-root/test/python/lib/python2.7/struct.py", line
1, in <module>
from _struct import *
ImportError: No module named _struct
make: *** [libinstall] Error 1

Any ideas, what I have done wrong?

Kind regards
Marten
 
Reply With Quote
 
 
 
 
Marten Lehmann
Guest
Posts: n/a
 
      09-16-2010
The strange thing is: This only happens when I'm compiling through
rpmbuild. Issuing the same commands (configure --enable-shared, make,
make install) directly on the shell works fine...
 
Reply With Quote
 
 
 
 
Thomas Jollans
Guest
Posts: n/a
 
      09-16-2010
On Thursday 16 September 2010, it occurred to Marten Lehmann to exclaim:
> Hello,
>
> I've build python 2.7 successfully by just calling configure, make and
> make install. But to use python within PostgreSQL, I need to built
> python with --enable-shared.
>
> I tried to do so (configure --enable-shared), but I see these lines
> several times in the log (but compiling continues):


Did you start with a clean source tree? If you just reconfigured and called
make again in the source tree where you already had built Python, make will
just re-use the old object files, which would be built without -fPIC and
whatever other options are required for the shared library linking to work.

>
> /usr/bin/ld: /test/python/lib/libpython2.7.a(abstract.o): relocation
> R_X86_64_32 against `a local symbol' can not be used when making a
> shared object; recompile with -fPIC
> /test/python/lib/libpython2.7.a: could not read symbols: Bad value
> collect2: ld returned 1 exit status


If you get this when building from a fresh source tree, I can't explain why
this might happen, but, again, starting afresh, this time adding -fPIC to the
CFLAGS, may work. But I expect that the configure script, or makefile, or
libtool, or whatever, should do this, hence my guess that maybe you're using
leftover object files.

(hint: make clean)

>
> Later, the compiling process ends completely:
>
> PYTHONPATH=/var/tmp/vrmd-python2-root/test/python/lib/python2.7
> LD_LIBRARY_PATH=/usr/src/redhat/BUILD/Python-2.7: \
> ./python -Wi -tt
> /var/tmp/vrmd-python2-root/test/python/lib/python2.7/compileall.py \
> -d /test/python/lib/python2.7 -f \
> -x
> 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \
> /var/tmp/vrmd-python2-root/test/python/lib/python2.7
> Traceback (most recent call last):
> File
> "/var/tmp/vrmd-python2-root/test/python/lib/python2.7/compileall.py",
> line 17, in <module>
> import struct
> File
> "/var/tmp/vrmd-python2-root/test/python/lib/python2.7/struct.py", line
> 1, in <module>
> from _struct import *
> ImportError: No module named _struct
> make: *** [libinstall] Error 1
>
> Any ideas, what I have done wrong?
>
> Kind regards
> Marten

 
Reply With Quote
 
Marten Lehmann
Guest
Posts: n/a
 
      09-16-2010
I digged into this one step further:

I compared the output of configure and make. For configure, there is no
change. But for make, I found out something, that I didn't expected:

When configure is called with a prefix to a location, where a valid
python installation already exists, it uses these locations for gcc,
although it shouldn't (we are about to compile a clean, brandnew python
version, so why should it include parts of an existing python
installation?).

Additionally to the default include paths

gcc [...] -I. -IInclude -I./Include -I/usr/local/include
-I/usr/src/redhat/BUILD/Python-2.7/Include
-I/usr/src/redhat/BUILD/Python-2.7 [...]

the path of the existing Python installation is added:
-I/test/python2/include

And additionally the default library paths and libs

gcc [...] -L/usr/local/lib -L. -lpython2.7 [...]

the path of the existing Python libs is added:

gcc [...9 -L/vrmd/python2/lib

So linking to python2.7 during make doesn't link to the freshly build
library, but to the existing in the system. And at least in my case,
where I'm switching from a python installation without --enabled-shared
to a new version including --enable-shared, this causes serious problems:

/usr/bin/ld: /vrmd/python2/lib/libpython2.7.a(abstract.o): relocation
R_X86_64_32 against `a local symbol' can not be used when making a
shared object; recompile with -fPIC
-/vrmd/python2/lib/libpython2.7.a: could not read symbols: Bad value
-collect2: ld returned 1 exit status

Is there any option I missed in configure or any variable that I might
set to correct this? Or should a file a bug to the python developers?
Deinstalling python before compiling or renaming the python directory is
not a good solution.

Kind regards
Marten
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Link Building Services| Link Building Company|Webs abrahim Java 0 12-27-2009 02:31 PM
Connecting Wireless Network from Building to Building Jim Wireless Networking 5 10-05-2007 03:54 PM
Firefighters at the site of WTC7 "Move away the building is going to blow up, get back the building is going to blow up." Midex Python 24 05-07-2007 04:23 AM
Wireless building-to-building 101 Tim Jacob Wireless Networking 2 02-17-2006 09:46 AM
Building to Building wireless Patriot Cisco 2 11-04-2003 05:07 PM



Advertisments