我一直在苦苦挣扎,因为我想交叉编译一个需要 Python 才能编译的应用程序。如果您好奇的话,情况是,当它转到 pyconfig.h 时,它会尝试包含以下文件:
arm-linux-gnueabihf/python2.7/pyconfig.h
不幸的是,它不存在。然后,我想安装 python 标头,因此我执行了以下操作:
sudo dpkg --add-architecture armhf
sudo apt-get update
我得到以下输出,
Hit:2 http://ports.ubuntu.com/ubuntu-ports xenial InRelease
Get:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [107 kB]
Get:4 http://ports.ubuntu.com/ubuntu-ports xenial-security InRelease [107 kB]
Hit:6 http://archive.ubuntu.com/ubuntu xenial-backports InRelease
Get:3 http://archive.ubuntu.com/ubuntu xenial InRelease [247 kB]
Get:7 http://security.ubuntu.com/ubuntu xenial-security/universe Sources [84.1 kB]
Get:8 http://ports.ubuntu.com/ubuntu-ports xenial-security/main armhf Packages [514 kB]
Get:9 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages [668 kB]
Get:10 http://security.ubuntu.com/ubuntu xenial-security/main i386 Packages [587 kB]
Get:5 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB]
Ign:11 http://archive.ubuntu.com/ubuntu xenial-backports/main armhf Packages
Ign:12 http://archive.ubuntu.com/ubuntu xenial-backports/universe armhf Packages
Get:13 http://ports.ubuntu.com/ubuntu-ports xenial-security/restricted armhf Packages [8480 B]
Get:14 http://ports.ubuntu.com/ubuntu-ports xenial-security/universe armhf Packages [375 kB]
Get:15 http://security.ubuntu.com/ubuntu xenial-security/restricted amd64 Packages [12.7 kB]
Get:16 http://security.ubuntu.com/ubuntu xenial-security/restricted i386 Packages [12.7 kB]
Get:17 http://security.ubuntu.com/ubuntu xenial-security/universe amd64 Packages [455 kB]
Get:18 http://security.ubuntu.com/ubuntu xenial-security/universe i386 Packages [385 kB]
Get:19 http://archive.ubuntu.com/ubuntu xenial/universe Sources [9802 kB]
Get:20 http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages [1558 kB]
Ign:21 http://archive.ubuntu.com/ubuntu xenial/main armhf Packages
Get:22 http://archive.ubuntu.com/ubuntu xenial/restricted amd64 Packages [14.1 kB]
Ign:23 http://archive.ubuntu.com/ubuntu xenial/restricted armhf Packages
Get:24 http://security.ubuntu.com/ubuntu xenial-security/multiverse amd64 Packages [3738 B]
Ign:25 http://security.ubuntu.com/ubuntu xenial-security/multiverse armhf Packages
Ign:25 http://security.ubuntu.com/ubuntu xenial-security/multiverse armhf Packages
Ign:25 http://security.ubuntu.com/ubuntu xenial-security/multiverse armhf Packages
Get:26 http://archive.ubuntu.com/ubuntu xenial/universe amd64 Packages [9827 kB]
Err:25 http://security.ubuntu.com/ubuntu xenial-security/multiverse armhf Packages
404 Not Found [IP: 91.189.88.152 80]
Get:27 http://archive.ubuntu.com/ubuntu xenial/universe i386 Packages [9804 kB]
Get:28 http://archive.ubuntu.com/ubuntu xenial/multiverse amd64 Packages [176 kB]
Ign:29 http://archive.ubuntu.com/ubuntu xenial/multiverse armhf Packages
Ign:11 http://archive.ubuntu.com/ubuntu xenial-backports/main armhf Packages
Ign:12 http://archive.ubuntu.com/ubuntu xenial-backports/universe armhf Packages
Get:30 http://archive.ubuntu.com/ubuntu xenial-updates/universe Sources [261 kB]
Get:31 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [1046 kB]
Ign:32 http://archive.ubuntu.com/ubuntu xenial-updates/main armhf Packages
Get:33 http://archive.ubuntu.com/ubuntu xenial-updates/restricted amd64 Packages [13.1 kB]
Ign:34 http://archive.ubuntu.com/ubuntu xenial-updates/restricted armhf Packages
Get:35 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [829 kB]
Ign:36 http://archive.ubuntu.com/ubuntu xenial-updates/universe armhf Packages
Get:37 http://archive.ubuntu.com/ubuntu xenial-updates/multiverse amd64 Packages [18.8 kB]
Ign:38 http://archive.ubuntu.com/ubuntu xenial-updates/multiverse armhf Packages
Ign:21 http://archive.ubuntu.com/ubuntu xenial/main armhf Packages
Ign:23 http://archive.ubuntu.com/ubuntu xenial/restricted armhf Packages
Ign:29 http://archive.ubuntu.com/ubuntu xenial/multiverse armhf Packages
Ign:11 http://archive.ubuntu.com/ubuntu xenial-backports/main armhf Packages
Ign:12 http://archive.ubuntu.com/ubuntu xenial-backports/universe armhf Packages
Ign:32 http://archive.ubuntu.com/ubuntu xenial-updates/main armhf Packages
Ign:34 http://archive.ubuntu.com/ubuntu xenial-updates/restricted armhf Packages
Ign:36 http://archive.ubuntu.com/ubuntu xenial-updates/universe armhf Packages
Ign:38 http://archive.ubuntu.com/ubuntu xenial-updates/multiverse armhf Packages
Ign:21 http://archive.ubuntu.com/ubuntu xenial/main armhf Packages
Ign:23 http://archive.ubuntu.com/ubuntu xenial/restricted armhf Packages
Ign:29 http://archive.ubuntu.com/ubuntu xenial/multiverse armhf Packages
Err:11 http://archive.ubuntu.com/ubuntu xenial-backports/main armhf Packages
404 Not Found [IP: 91.189.88.149 80]
Ign:12 http://archive.ubuntu.com/ubuntu xenial-backports/universe armhf Packages
Ign:32 http://archive.ubuntu.com/ubuntu xenial-updates/main armhf Packages
Ign:34 http://archive.ubuntu.com/ubuntu xenial-updates/restricted armhf Packages
Ign:36 http://archive.ubuntu.com/ubuntu xenial-updates/universe armhf Packages
Ign:38 http://archive.ubuntu.com/ubuntu xenial-updates/multiverse armhf Packages
Err:21 http://archive.ubuntu.com/ubuntu xenial/main armhf Packages
404 Not Found [IP: 91.189.88.149 80]
Ign:23 http://archive.ubuntu.com/ubuntu xenial/restricted armhf Packages
Ign:29 http://archive.ubuntu.com/ubuntu xenial/multiverse armhf Packages
Err:32 http://archive.ubuntu.com/ubuntu xenial-updates/main armhf Packages
404 Not Found [IP: 91.189.88.149 80]
Ign:34 http://archive.ubuntu.com/ubuntu xenial-updates/restricted armhf Packages
Ign:36 http://archive.ubuntu.com/ubuntu xenial-updates/universe armhf Packages
Ign:38 http://archive.ubuntu.com/ubuntu xenial-updates/multiverse armhf Packages
Fetched 2452 kB in 2s (1020 kB/s)
Reading package lists... Done
E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial-backports/main/binary-armhf/Packages 404 Not Found [IP: 91.189.88.149 80]
E: Failed to fetch http://security.ubuntu.com/ubuntu/dists/xenial-security/multiverse/binary-armhf/Packages 404 Not Found [IP: 91.189.88.152 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial/main/binary-armhf/Packages 404 Not Found [IP: 91.189.88.149 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial-updates/main/binary-armhf/Packages 404 Not Found [IP: 91.189.88.149 80]
E: Some index files failed to download. They have been ignored, or old ones used instead.
我在网上搜索了一下,很多人说解决办法是在 /etc/apt/sources.list 中区分哪些存储库适用于 armhf 架构,哪些存储库适用于 amd64,i386。这根本不起作用(我也不知道我做得好不好,我对 sources.list 了解不多),当我执行此命令时:
sudo apt-get install libpython2.7-dev:armhf
我得到:
The following packages have unmet dependencies:
libpython2.7-dev:armhf : Depends: libpython2.7-stdlib:armhf (= 2.7.12-1ubuntu0~16.04.2) but it is not going to be installed
Depends: libpython2.7:armhf (= 2.7.12-1ubuntu0~16.04.2) but it is not going to be installed
Depends: libexpat1-dev:armhf but it is not going to be installed
Recommends: libc6-dev:armhf but it is not going to be installed or
libc-dev:armhf
E: Unable to correct problems, you have held broken packages
你知道我在哪一步搞砸了吗?我不确定,我会很感激你的帮助,谢谢。
答案1
我无法解决这个问题,但我设法编译了,pyconf.h 需要 arm-linux-gnueabihf-hf pyconf.h,因此我在 ARM 设备上安装了 python2.7 和 python3.5 开发包(python-dev 和 python3-dev),然后将其复制回我的 PC 上查找这些 pyconf.h 文件的位置。这并不优雅,我不喜欢它,但它确实有效。
答案2
我在 sources.list 中添加了以下内容:
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ bionic main restricted universe multiverse
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ bionic-updates main restricted universe multiverse
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ bionic-backports main restricted universe multiverse
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ bionic-security main restricted universe multiverse
然后跑步
sudo dpkg --add-architecture armhf
sudo apt-get update
sudo apt-get install libpython2.7-dev:armhf