Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cross Compiling Python Extensions

I have a problem with cross-compiling netifaces extension under Buildroot Linux distro for ARM (Python 2.7.2). According to this blog http://whatschrisdoing.com/blog/2009/10/16/cross-compiling-python-extensions/ I've defined CC, LDSHARE etc. environment variables, but distutils/setuptools doesn't take CC into account so all tests will fail:

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

Are there any other cross-compile examples/tutorials or what am I doing wrong?

like image 949
yegorich Avatar asked Dec 23 '11 09:12

yegorich


People also ask

Can you cross-compile Python?

This tool requires Python 3.5 or higher (host and build). Significant work has gone into cross-compiling Python in newer versions, and many of the techniques needed to do the cross compilation properly are not available on older releases. This tool currently only supports Linux build machines.

Why is cross-compiling so hard?

"building a cross-compiler is significantly harder than building a compiler that targets the platform it runs on." The problem exists due to the way libraries are built and accessed. In the normal situation all the libraries are located in a specific spot, and are used by all apps on that system.

Is cross-compiling slow?

The usual case for cross-compiling is that your target is so woefully slow and under-powered that you would be insane to do anything else.

What is cross-compiling code?

Cross-compilation is the act of compiling code for one computer system (often known as the target) on a different system, called the host. It's a very useful technique, for instance when the target system is too small to host the compiler and all relevant files.


1 Answers

Make sure you have installed the distutilscross package as noted in the article you linked. This adds the -x option and support for PYTHONXCPREFIX/LDSHARED/etc environment variables.

like image 54
A. Wilcox Avatar answered Oct 31 '22 02:10

A. Wilcox