python本地代码_从源代码构建python时如何忽略本地python

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?

解决方案

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值