使用“ - enable-shared”的奇怪的Python编译结果旗 [英] Strange Python compilation results with "--enable-shared" flag

查看:677
本文介绍了使用“ - enable-shared”的奇怪的Python编译结果旗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Debian(与Python-2.7.3一起),试图从源代码编译Python-2.7.6与Apache一起使用mod_wsgi。



显然,根据许多答案,编译mod_wsgi时,你必须使用--enable-shared。



执行以下步骤:

  ./ configure --enable-shared --prefix = / usr / local / bin / python-2.7.6 
make
make install

然后检查交互式shell @



usr / local / bin / python-2.7.6 / bin / python



我遇到了Python 2.7.3(默认,2013年1月2日14:09: 21)etc



为什么会导致Python 2.7.3?



这是结果:

  linux-vdso.so.1 => (0x00007fff271ff000)
libpython2.7.so.1.0 => /usr/lib/libpython2.7.so.1.0(0x00007f1545638000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0(0x00007f154541c000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2(0x00007f1545217000)
libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1(0x00007f1545014000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6(0x00007f1544d92000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6(0x00007f1544a06000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1(0x00007f15447ef000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1(0x00007f15445d9000)
/lib64/ld-linux-x86-64.so.2(0x00007f1545b40000)

如何停止使用系统库,而使用本地编译的版本?



我知道,这是一个很容易我只是恢复使用系统安装的Python版本,而真实世界的差异是零。但是这种行为看起来很奇怪。

解决方案

当你做Python的时候,运行它:

  LD_RUN_PATH = / usr / local / lib make 

设置环境变量LD_RUN_PATH强制'python'可执行程序在/ usr / local / lib之前的/ usr / lib中查找Python共享库。



这在mod_wsgi文档中提到。





在再次执行此操作之前,请确保您执行了make distclean并重新运行配置,以确保您没有旧的构建产品。


I am using Debian (which comes with Python-2.7.3), trying to compile Python-2.7.6 from source for use with mod_wsgi alongside Apache.

Apparently you must use --enable-shared when compiling for mod_wsgi usage, according to numerous answers.

Following these steps:

./configure --enable-shared --prefix=/usr/local/bin/python-2.7.6
make
make install

And then checking the interactive shell @

/usr/local/bin/python-2.7.6/bin/python

I am greeted with "Python 2.7.3 (default, Jan 2 2013, 14:09:21)" etc

Why is it resulting in Python 2.7.3?

I tried ldd against the executable and this is the result:

linux-vdso.so.1 =>  (0x00007fff271ff000)
libpython2.7.so.1.0 => /usr/lib/libpython2.7.so.1.0 (0x00007f1545638000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f154541c000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f1545217000)
libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007f1545014000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f1544d92000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f1544a06000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f15447ef000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f15445d9000)
/lib64/ld-linux-x86-64.so.2 (0x00007f1545b40000)

How do I stop it from using the system library and instead use the locally compiled version?

I know that it is a lot easier for me to just revert to using the system installed Python version, and that the real-world difference is zero. But this behaviour seems strange.

解决方案

When you do the make of Python, run it as:

LD_RUN_PATH=/usr/local/lib make

Setting the environment variable LD_RUN_PATH forces 'python' executable generated to look in /usr/local/lib before /usr/lib for Python shared library.

This is mentioned in the mod_wsgi documentation.

Before doing this again, make sure you do a 'make distclean' and rerun configure to make sure you haven't got old build products around.

这篇关于使用“ - enable-shared”的奇怪的Python编译结果旗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆