无法交叉编译 Python-2.7.18 for x86,uclibc

Unable to cross-compile Python-2.7.18 for x86,uclibc

我正在尝试使用 crosstool-ng 示例工具链为 x86、uclibc 机器交叉编译 Python 2.7.18。使用的命令如下:

CONFIG_SITE=config.site CC=/home/msainz/x-tools/x86_64-unknown-linux-uclibc/bin/x86_64-unknown-linux-uclibc-gcc CXX=/home/msainz/x-tools/x86_64-unknown-linux-uclibc/bin/x86_64-unknown-linux-uclibc-g++ AR=/home/msainz/x-tools/x86_64-unknown-linux-uclibc/bin/x86_64-unknown-linux-uclibc-ar RANLIB=/home/msainz/x-tools/x86_64-unknown-linux-uclibc/bin/x86_64-unknown-linux-uclibc-ranlib READELF=/home/msainz/x-tools/x86_64-unknown-linux-uclibc/bin/x86_64-unknown-linux-uclibc-readelf LDFLAGS="-L/home/msainz/Projects/Selene/WP3/local/uclibc/base_rootfs/lib -L/home/msainz/Projects/Selene/WP3/local/uclibc/base_rootfs/usr/lib" CFLAGS="-I/home/msainz/Projects/Selene/WP3/local/uclibc/base_rootfs/usr/include -I/home/msainz/Projects/Selene/WP3/local/uclibc/base_rootfs/include" CPPFLAGS="-I/home/msainz/Projects/Selene/WP3/local/uclibc/base_rootfs/usr/include -I/home/msainz/Projects/Selene/WP3/local/uclibc/base_rootfs/include" ./configure --enable-shared --host=x86_64-unknown-linux-uclibc --build=x86_64 --disable-ipv6 --prefix=/home/msainz/Projects/python2_top_uclibc/

其次是

PATH=$PATH:/home/msainz/Projects/python2_top_glibc/bin/ make

PATH=$PATH:/home/msainz/Projects/python2_top_glibc/bin/ make install

执行结束,出现以下错误:

fi /home/msainz/x-tools/x86_64-unknown-linux-uclibc/bin/x86_64-unknown-linux-uclibc-gcc -L/home/msainz/Projects/Selene/WP3/local/uclibc/base_rootfs/lib -L/home/msainz/Projects/Selene/WP3/local/uclibc/base_rootfs/usr/lib -Xlinker -export-dynamic -o python \ Modules/python.o \ -L. -lpython2.7 -ldl -lpthread -lm _PYTHON_PROJECT_BASE=/home/msainz/Projects/Python-2.7.18 _PYTHON_HOST_PLATFORM=linux2-x86_64 PYTHONPATH=./Lib:./Lib/plat-linux2 python -S -m sysconfig --generate-posix-vars ;\ if test $? -ne 0 ; then \ echo "generate-posix-vars failed" ; \ rm -f ./pybuilddir.txt ; \ exit 1 ; \ fi python: error while loading shared libraries: libc.so.0: cannot open shared object file: No such file or directory generate-posix-vars failed make: *** [Makefile:523: pybuilddir.txt] Error 1

python2_top_glibc 目录包含以前的 Python-2.7.18 安装,但用于编译完美的本机 glibc。 libc.so.0 实际上在目标系统的base_rootfs 中,在./configure 阶段链接。我现在被困在这了。任何线索将不胜感激。将根据需要提供任何其他信息。

提前致谢。

python: cannot open shared object file: No such file or directory

这是一个 运行 时间加载程序错误。您正在尝试 运行 与 libc.so.0.

链接的 python 可执行文件

如果此可执行文件实际上可以 运行 在您的主机环境中,您可以通过将 base_rootfs 库添加到 LD_LIBRARY_PATH 来启用它。否则,您需要在构建过程的这个步骤中使用主机 python 可执行文件,或者完全禁用它。