Python distutils gcc路径 [英] Python distutils gcc path
问题描述
我正在尝试交叉编译pycrypto软件包,但是越来越近了,但是我遇到了一个我不知道的问题。
I'm trying to cross-compile the pycrypto package, and I'm getting closer and closer however, I've hit an issue I just can't figure out.
我希望distutils使用交叉编译专用的gcc-,因此我设置了CC env var,并且似乎尊重第一次编译器调用的设置,但是就是这样。
I want distutils to use the cross-compile specific gcc- so I set the CC env var and it seems to respect the setting for the first invocation of the compiler, but thats it.
export CC="/opt/teeos/buildroot/output/host/usr/bin/i586-linux-gcc"
/opt/teeos/buildroot/output/host/usr/bin/i586-linux-gcc -fno-strict-aliasing -fwrapv -Wall -Wstrict-prototypes -fPIC -std=c99 --sysroot=/opt/teeos/buildroot/output/staging -I/opt/teeos/buildroot/output/staging/usr/include/python2.7 -O3 -fomit-frame-pointer -Isrc/ -I/usr/include/python2.7 -c src/_fastmath.c -o build/temp.linux-i686-2.7/src/_fastmath.o
gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions build/temp.linux-i686-2.7/src/_fastmath.o -lgmp -o build/lib.linux-i686-2.7/Crypto/PublicKey/_fastmath.so
unable to execute gcc: No such file or directory
我暂时将系统gcc移到了无法找到的位置。
I temporarily moved my systems gcc so it can't be found.
如何使distutils在每次调用编译器时都尊重 CC = / opt / buildroot ...
选项/设置我要distutils使用的GCC / LD的路径?
How do I make distutils respect the CC=/opt/buildroot...
option for every invocation of the compiler / set the path to the GCC / LD I want distutils to use?
推荐答案
这听起来与我最近为< a href = https://stackoverflow.com/questions/5967065/python-distutils-not-using-correct-version-of-gcc/5968410#5968410>自定义distutils编译器。您还需要定义 LDSHARED
,这是用于产生最终共享库的命令。看看是否可行:
This sounds similar to another answer I recently gave for customizing the distutils compiler. You'll also need to define LDSHARED
which is the command used to produce the final shared object. See if this works:
>>> from distutils import sysconfig
>>> sysconfig.get_config_var('LDSHARED')
'gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions'
>>> sysconfig.get_config_var('CC')
'gcc -pthread'
然后替换 gcc
,并在 CC
和 LDSHARED
环境中使用所需的编译器和选项变量:
Then replace gcc
with your desired compiler and options in the CC
and LDSHARED
environment variables:
% LDSHARED="i586-linux-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions" \
CC="i586-linux-gcc -pthread" python setup.py build
这篇关于Python distutils gcc路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!