Python3交叉编译失败

时间:2020-01-06 20:06:08

标签: python-3.x gcc g++ cross-platform

我已经使用crosstool-NG 1.24.0构建了sdk

target:

Architecture- i686 (32 bit amd)
Binutils:2.32 
kernel: 4.9.156
Glibc: 2.19
Gcc: 7.4.0

SDK构建成功。现在我正在尝试交叉编译python-3.6.9

export PATH=/home/ach/x-tools/i686-pc-linux-gnu/bin:$PATH

export CC=/home/ach/x-tools/i686-pc-linux-gnu/bin/i686-pc-linux-gnu-gcc
export CPP=/home/ach/x-tools/i686-pc-linux-gnu/bin/i686-pc-linux-gnu-cpp
export CXX=/home/ach/x-tools/i686-pc-linux-gnu/bin/i686-pc-linux-gnu-g++
export INSTALL_DIR=/home/ach/Downloads/cross-python/compiled-python3
export LDFLAGS="-L/home/ach/Downloads/cross-openssl/compiled-openssl/lib/ -L/home/ach/Downloads/cross-zlib/compiled-zlib/lib" &&
export LD_LIBRARY_PATH="/home/ach/Downloads/cross-openssl/compiled-openssl/lib/:/home/ach/Downloads/cross-zlib/compiled-zlib/lib" &&
export CPPFLAGS=" -I/home/ach/x-tools/i686-pc-linux-gnu/i686-pc-linux-gnu/sysroot/usr/include -I/home/ach/Downloads/cross-openssl/compiled-openssl/include/ -I/home/ach/Downloads/cross-zlib/compiled-zlib/include"


../Python-3.6.9/configure \
    --target=x86-pc-linux-gnu \
    --prefix=$INSTALL_DIR \
    --with-libm=/home/ach/x-tools/i686-pc-linux-gnu/i686-pc-linux-gnu/sysroot/usr/lib/libm.so \
    --with-libc=/home/ach/x-tools/i686-pc-linux-gnu/i686-pc-linux-gnu/sysroot/usr/lib/libc.so \
    --with-ensurepip=install \
    --disable-ipv6 \
    --enable-shared \
    ac_cv_file__dev_ptmx=no \
    ac_cv_file__dev_ptc=no \
    ac_cv_have_long_long_format=yes

执行命令 make

时有很多错误
creating build/temp.linux-x86_64-3.6/home/ach/Downloads/cross-python/Python-3.6.9/Modules
/home/ach/x-tools/i686-pc-linux-gnu/bin/i686-pc-linux-gnu-gcc -pthread -fPIC -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -I../Python-3.6.9/Include -IObjects -IPython -I. -I/home/ach/x-tools/i686-pc-linux-gnu/i686-pc-linux-gnu/sysroot/usr/include -I/home/ach/Downloads/cross-openssl/compiled-openssl/include/ -I/home/ach/Downloads/cross-zlib/compiled-zlib/include -I/usr/include/i386-linux-gnu -I/usr/local/include -I/home/ach/Downloads/cross-python/Python-3.6.9/Include -I/home/ach/Downloads/cross-python/build-python3 -c /home/ach/Downloads/cross-python/Python-3.6.9/Modules/_struct.c -o build/temp.linux-x86_64-3.6/home/ach/Downloads/cross-python/Python-3.6.9/Modules/_struct.o
In file included from /home/ach/x-tools/i686-pc-linux-gnu/i686-pc-linux-gnu/sysroot/usr/include/features.h:378:0,
                 from /home/ach/x-tools/i686-pc-linux-gnu/i686-pc-linux-gnu/sysroot/usr/include/limits.h:25,
                 from /home/ach/x-tools/i686-pc-linux-gnu/lib/gcc/i686-pc-linux-gnu/7.4.0/include-fixed/limits.h:194,
                 from /home/ach/x-tools/i686-pc-linux-gnu/lib/gcc/i686-pc-linux-gnu/7.4.0/include-fixed/syslimits.h:7,
                 from /home/ach/x-tools/i686-pc-linux-gnu/lib/gcc/i686-pc-linux-gnu/7.4.0/include-fixed/limits.h:34,
                 from ../Python-3.6.9/Include/Python.h:11,
                 from /home/ach/Downloads/cross-python/Python-3.6.9/Modules/_struct.c:8:
/usr/include/i386-linux-gnu/sys/cdefs.h:467:49: error: missing binary operator before token "("
 #if __GNUC_PREREQ (4,8) || __glibc_clang_prereq (3,5)
                                                 ^
In file included from ../Python-3.6.9/Include/Python.h:25:0,
                 from /home/ach/Downloads/cross-python/Python-3.6.9/Modules/_struct.c:8:
/home/ach/x-tools/i686-pc-linux-gnu/i686-pc-linux-gnu/sysroot/usr/include/stdio.h:48:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'typedef'
 typedef struct _IO_FILE FILE;
   ...

首先,这是什么意思

/usr/include/i386-linux-gnu/sys/cdefs.h:467:49: error: missing binary operator before token "("
 #if __GNUC_PREREQ (4,8) || __glibc_clang_prereq (3,5)

相关问题here,但不幸的是没有答案...

第二个为什么它引用以下路径,尽管我将CPPFLAGS设置为sysroot / include

/usr/include/i386-linux-gnu/sys/cdefs.h


$ /home/ach/x-tools/i686-pc-linux-gnu/bin/i686-pc-linux-gnu-gcc -v
gcc version 7.4.0 (crosstool-NG 1.24.0) 
COLLECT_GCC_OPTIONS='-E' '-v' '-mtune=generic' '-march=i686'
 /home/ach/x-tools/i686-pc-linux-gnu/libexec/gcc/i686-pc-linux-gnu/7.4.0/cc1 -E -quiet -v - -mtune=generic -march=i686
ignoring nonexistent directory "/home/ach/x-tools/i686-pc-linux-gnu/i686-pc-linux-gnu/sysroot/home/ach/x-tools/i686-pc-linux-gnu/i686-pc-linux-gnu/sysroot/include"
#include "..." search starts here:
#include <...> search starts here:
 /home/ach/x-tools/i686-pc-linux-gnu/lib/gcc/i686-pc-linux-gnu/7.4.0/include
 /home/ach/x-tools/i686-pc-linux-gnu/lib/gcc/i686-pc-linux-gnu/7.4.0/include-fixed
 /home/ach/x-tools/i686-pc-linux-gnu/lib/gcc/i686-pc-linux-gnu/7.4.0/../../../../i686-pc-linux-gnu/include
 /home/ach/x-tools/i686-pc-linux-gnu/i686-pc-linux-gnu/sysroot/usr/include

我在

上也有cdefs.h
/home/ach/x-tools/i686-pc-linux-gnu/i686-pc-linux-gnu/sysroot/usr/include/sys/cdefs.h

我的SDK位于

/home/ach/x-tools/i686-pc-linux-gnu

如何解决此参考问题?

谢谢

0 个答案:

没有答案