Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
499 views
in Technique[技术] by (71.8m points)

configure - How to ignore local python when building python from source

When I try to build my own version of Python using:

./configure --enable-shared --prefix=/app/vendor/python-dev && make && make install

I see some errors during installation:

/usr/bin/ld: /usr/local/lib/libpython2.7.a(abstract.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC /usr/local/lib/libpython2.7.a: could not read symbols: Bad value

The problem starts when the linker tries to use /usr/local/lib/libpython2.7.a and not the newly compiled library.

How can I prevent the linker (configure/make) from using the python libraries installed on the system?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This looks to be a misfeature of the setup.py script always including /usr/local in the search path when make builds the target sharedmods.

You'll have to manually frob the setup.py, so do the...

./configure --enable-shared --prefix=/app/vendor/python-dev

...first, then edit setup.py, find lines 442, 443, and 444 which should look like this...

if not cross_compiling:
    add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
    add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')

...and comment them out so they look like this...

# if not cross_compiling
    # add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
    # add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')

...then the make should work.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...