交叉编译Python扩展

18 投票
2 回答
6989 浏览
提问于 2025-04-17 08:54

我在使用Buildroot Linux系统为ARM架构交叉编译netifaces扩展时遇到了问题(Python版本是2.7.2)。根据这篇博客http://whatschrisdoing.com/blog/2009/10/16/cross-compiling-python-extensions/,我已经设置了CC、LDSHARE等环境变量,但distutils/setuptools并没有考虑到CC的设置,所以所有的测试都会失败:

running build
Setting prefix
Setting prefix
running build_ext
checking for getifaddrs... not found. (cached)
checking for getnameinfo... not found. (cached)
checking for socket IOCTLs... not found. (cached)
checking for optional header files... netash/ash.h netatalk/at.h netax25/ax25.h neteconet/ec.h netipx/ipx.h netpacket/packet.h linux/irda.h linux/atm.h linux/llc.h linux/tipc.h linux/dn.h. (cached)
checking whether struct sockaddr has a length field... no. (cached)
checking which sockaddr_xxx structs are defined... at ax25 in in6 ipx un ash ec ll  atmpvc atmsvc dn irda llc. (cached)
building 'netifaces' extension

有没有其他的交叉编译示例或教程,或者我哪里做错了呢?

2 个回答

-1

我不知道你还关不关心这个问题。看起来你已经有了一些构建目标,所以程序不再编译这个C程序了。试着把“build”文件夹下面的所有文件和目录都清理掉,然后再重新构建一次。

1

确保你已经安装了文中提到的 distutilscross 包。这个包会增加一个 -x 选项,并支持 PYTHONXCPREFIX、LDSHARED 等环境变量。

撰写回答