Cross-compile python packge
-
Hi, I'm trying to get the Alexa-Pi client to run on the Omega2+.
In the dependencies of the project, there's pyaudio which throws some errors related to
'mipsel-openwrt-linux-musl-gcc': No such file or directory
when I try to install it using pip. After reading pars of the documentation I found out that the only way I could do this is by cross-compiling the c code from the package. So I got a Debian 9 instance running, built the source, cloned the pyaudio code and tried to compile but I get a lot of errors which I have not been able to solve yet.$ /home/admin/source/staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl/bin/mipsel-openwrt-linux-musl-gcc -I /usr/include/ -I /usr/include/python2.7/ src/_portaudiomodule.c In file included from /usr/include/libio.h:31:0, from /usr/include/stdio.h:74, from src/_portaudiomodule.c:27: /usr/include/_G_config.h:46:20: error: unknown type name '__gnuc_va_list' #define _G_va_list __gnuc_va_list ^ /usr/include/libio.h:44:21: note: in expansion of macro '_G_va_list' #define _IO_va_list _G_va_list ^ /usr/include/libio.h:460:4: note: in expansion of macro '_IO_va_list' _IO_va_list, int *__restrict); ^ /usr/include/_G_config.h:46:20: error: unknown type name '__gnuc_va_list' #define _G_va_list __gnuc_va_list ^ /usr/include/libio.h:44:21: note: in expansion of macro '_G_va_list' #define _IO_va_list _G_va_list ^ /usr/include/libio.h:462:5: note: in expansion of macro '_IO_va_list' _IO_va_list); ^ /usr/include/_G_config.h:46:20: error: unknown type name '__gnuc_va_list' #define _G_va_list __gnuc_va_list ^ /usr/include/stdio.h:79:9: note: in expansion of macro '_G_va_list' typedef _G_va_list va_list; ^ In file included from src/_portaudiomodule.c:27:0: /usr/include/stdio.h:79:20: error: conflicting types for 'va_list' typedef _G_va_list va_list; ^ In file included from /home/admin/source/staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl/include/stdarg.h:10:0, from /usr/include/libio.h:49, from /usr/include/stdio.h:74, from src/_portaudiomodule.c:27: /home/admin/source/staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl/include/bits/alltypes.h:6:27: note: previous declaration of 'va_list' was here typedef __builtin_va_list va_list; ^ In file included from /usr/include/libio.h:31:0, from /usr/include/stdio.h:74, from src/_portaudiomodule.c:27: /usr/include/_G_config.h:46:20: error: unknown type name '__gnuc_va_list' #define _G_va_list __gnuc_va_list ^ /usr/include/stdio.h:374:8: note: in expansion of macro '_G_va_list' _G_va_list __arg); ^ /usr/include/_G_config.h:46:20: error: unknown type name '__gnuc_va_list' #define _G_va_list __gnuc_va_list ^ /usr/include/stdio.h:379:54: note: in expansion of macro '_G_va_list' extern int vprintf (const char *__restrict __format, _G_va_list __arg); ^ /usr/include/_G_config.h:46:20: error: unknown type name '__gnuc_va_list' #define _G_va_list __gnuc_va_list ^ /usr/include/stdio.h:382:8: note: in expansion of macro '_G_va_list' _G_va_list __arg) __THROWNL; ^ /usr/include/_G_config.h:46:20: error: unknown type name '__gnuc_va_list' #define _G_va_list __gnuc_va_list ^ /usr/include/stdio.h:393:42: note: in expansion of macro '_G_va_list' const char *__restrict __format, _G_va_list __arg) ^ /usr/include/_G_config.h:46:20: error: unknown type name '__gnuc_va_list' #define _G_va_list __gnuc_va_list ^ /usr/include/stdio.h:415:8: note: in expansion of macro '_G_va_list' _G_va_list __arg) ^ /usr/include/_G_config.h:46:20: error: unknown type name '__gnuc_va_list' #define _G_va_list __gnuc_va_list ^ /usr/include/stdio.h:474:7: note: in expansion of macro '_G_va_list' _G_va_list __arg) ^ /usr/include/_G_config.h:46:20: error: unknown type name '__gnuc_va_list' #define _G_va_list __gnuc_va_list ^ /usr/include/stdio.h:481:53: note: in expansion of macro '_G_va_list' extern int vscanf (const char *__restrict __format, _G_va_list __arg) ^ /usr/include/_G_config.h:46:20: error: unknown type name '__gnuc_va_list' #define _G_va_list __gnuc_va_list ^ /usr/include/stdio.h:486:40: note: in expansion of macro '_G_va_list' const char *__restrict __format, _G_va_list __arg) ^ In file included from /usr/include/features.h:364:0, from /usr/include/stdio.h:27, from src/_portaudiomodule.c:27: /usr/include/_G_config.h:46:20: error: unknown type name '__gnuc_va_list' #define _G_va_list __gnuc_va_list ^ /usr/include/sys/cdefs.h:177:46: note: in definition of macro '__REDIRECT' # define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias)) ^ /usr/include/stdio.h:498:37: note: in expansion of macro '_G_va_list' const char *__restrict __format, _G_va_list __arg), ^ /usr/include/_G_config.h:46:20: error: unknown type name '__gnuc_va_list' #define _G_va_list __gnuc_va_list ^ /usr/include/sys/cdefs.h:177:46: note: in definition of macro '__REDIRECT' # define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias)) ^ /usr/include/stdio.h:502:5: note: in expansion of macro '_G_va_list' _G_va_list __arg), __isoc99_vscanf) ^ /usr/include/_G_config.h:46:20: error: unknown type name '__gnuc_va_list' #define _G_va_list __gnuc_va_list ^ /usr/include/sys/cdefs.h:185:11: note: in definition of macro '__REDIRECT_NTH' name proto __asm__ (__ASMNAME (#alias)) __THROW ^ /usr/include/stdio.h:507:8: note: in expansion of macro '_G_va_list' _G_va_list __arg), __isoc99_vsscanf) ^ In file included from /usr/include/python2.7/Python.h:8:0, from src/_portaudiomodule.c:28: /usr/include/python2.7/pyconfig.h:83:5: error: #error unknown multiarch location for pyconfig.h # error unknown multiarch location for pyconfig.h ^ In file included from /usr/include/bits/local_lim.h:38:0, from /usr/include/bits/posix1_lim.h:160, from /usr/include/limits.h:143, from /usr/include/python2.7/Python.h:19, from src/_portaudiomodule.c:28: /usr/include/linux/limits.h:6:0: warning: "NGROUPS_MAX" redefined #define NGROUPS_MAX 65536 /* supplemental group IDs are available */ ^ In file included from /usr/include/limits.h:123:0, from /usr/include/python2.7/Python.h:19, from src/_portaudiomodule.c:28: /home/admin/source/staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl/include/limits.h:51:0: note: this is the location of the previous definition #define NGROUPS_MAX 32 ^ In file included from /usr/include/bits/posix1_lim.h:160:0, from /usr/include/limits.h:143, from /usr/include/python2.7/Python.h:19, from src/_portaudiomodule.c:28: /usr/include/bits/local_lim.h:64:0: warning: "PTHREAD_KEYS_MAX" redefined #define PTHREAD_KEYS_MAX 1024 ^ In file included from /usr/include/limits.h:123:0, from /usr/include/python2.7/Python.h:19, from src/_portaudiomodule.c:28: /home/admin/source/staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl/include/limits.h:63:0: note: this is the location of the previous definition #define PTHREAD_KEYS_MAX 128 ^ In file included from /usr/include/bits/posix1_lim.h:160:0, from /usr/include/limits.h:143, from /usr/include/python2.7/Python.h:19, from src/_portaudiomodule.c:28: /usr/include/bits/local_lim.h:69:0: warning: "PTHREAD_DESTRUCTOR_ITERATIONS" redefined #define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS ^ In file included from /usr/include/limits.h:123:0, from /usr/include/python2.7/Python.h:19, from src/_portaudiomodule.c:28: /home/admin/source/staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl/include/limits.h:65:0: note: this is the location of the previous definition #define PTHREAD_DESTRUCTOR_ITERATIONS 4 ^ In file included from /usr/include/bits/posix1_lim.h:160:0, from /usr/include/limits.h:143, from /usr/include/python2.7/Python.h:19, from src/_portaudiomodule.c:28: /usr/include/bits/local_lim.h:81:0: warning: "PTHREAD_STACK_MIN" redefined #define PTHREAD_STACK_MIN 16384 ^ In file included from /usr/include/limits.h:123:0, from /usr/include/python2.7/Python.h:19, from src/_portaudiomodule.c:28: /home/admin/source/staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl/include/limits.h:64:0: note: this is the location of the previous definition #define PTHREAD_STACK_MIN 2048 ^ In file included from /usr/include/bits/posix1_lim.h:160:0, from /usr/include/limits.h:143, from /usr/include/python2.7/Python.h:19, from src/_portaudiomodule.c:28: /usr/include/bits/local_lim.h:84:0: warning: "DELAYTIMER_MAX" redefined #define DELAYTIMER_MAX 2147483647 ^ In file included from /usr/include/limits.h:123:0, from /usr/include/python2.7/Python.h:19, from src/_portaudiomodule.c:28: /home/admin/source/staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl/include/limits.h:68:0: note: this is the location of the previous definition #define DELAYTIMER_MAX 0x7fffffff ^ In file included from /usr/include/bits/posix1_lim.h:160:0, from /usr/include/limits.h:143, from /usr/include/python2.7/Python.h:19, from src/_portaudiomodule.c:28: /usr/include/bits/local_lim.h:93:0: warning: "HOST_NAME_MAX" redefined #define HOST_NAME_MAX 64 ^ In file included from /usr/include/limits.h:123:0, from /usr/include/python2.7/Python.h:19, from src/_portaudiomodule.c:28: /home/admin/source/staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl/include/limits.h:59:0: note: this is the location of the previous definition #define HOST_NAME_MAX 255 ^ In file included from /usr/include/bits/posix1_lim.h:160:0, from /usr/include/limits.h:143, from /usr/include/python2.7/Python.h:19, from src/_portaudiomodule.c:28: /usr/include/bits/local_lim.h:99:0: warning: "SEM_VALUE_MAX" redefined #define SEM_VALUE_MAX (2147483647) ^ In file included from /usr/include/limits.h:123:0, from /usr/include/python2.7/Python.h:19, from src/_portaudiomodule.c:28: /home/admin/source/staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl/include/limits.h:66:0: note: this is the location of the previous definition #define SEM_VALUE_MAX 0x7fffffff ^ In file included from /usr/include/limits.h:147:0, from /usr/include/python2.7/Python.h:19, from src/_portaudiomodule.c:28: /usr/include/bits/posix2_lim.h:88:0: warning: "RE_DUP_MAX" redefined #define RE_DUP_MAX (0x7fff) ^ In file included from /usr/include/limits.h:123:0, from /usr/include/python2.7/Python.h:19, from src/_portaudiomodule.c:28: /home/admin/source/staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl/include/limits.h:82:0: note: this is the location of the previous definition #define RE_DUP_MAX 255 ^ In file included from /usr/include/python2.7/pyport.h:4:0, from /usr/include/python2.7/Python.h:58, from src/_portaudiomodule.c:28: /usr/include/python2.7/pyconfig.h:83:5: error: #error unknown multiarch location for pyconfig.h # error unknown multiarch location for pyconfig.h ^ In file included from /usr/include/python2.7/Python.h:58:0, from src/_portaudiomodule.c:28: /usr/include/python2.7/pyport.h:895:2: error: #error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)." #error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)." ^ In file included from /usr/include/python2.7/pymath.h:4:0, from /usr/include/python2.7/Python.h:77, from src/_portaudiomodule.c:28: /usr/include/python2.7/pyconfig.h:83:5: error: #error unknown multiarch location for pyconfig.h # error unknown multiarch location for pyconfig.h ^ src/_portaudiomodule.c: In function '_pyAudio_paHostApiInfo_get_name': src/_portaudiomodule.c:509:10: warning: implicit declaration of function 'PyUnicode_FromString' [-Wimplicit-function-declaration] return PyUnicode_FromString(self->apiInfo->name); ^ src/_portaudiomodule.c:509:10: warning: return makes pointer from integer without a cast [-Wint-conversion] src/_portaudiomodule.c: In function 'pa_get_version_text': src/_portaudiomodule.c:1196:10: warning: return makes pointer from integer without a cast [-Wint-conversion] return PyUnicode_FromString(Pa_GetVersionText()); ^ src/_portaudiomodule.c: In function 'init_portaudio': src/_portaudiomodule.c:2594:3: warning: implicit declaration of function 'PyEval_InitThreads' [-Wimplicit-function-declaration] PyEval_InitThreads(); ^
P.S. This is the first time I try to cross-compile, my approach could be completely wrong.
-
Running
mipsel-openwrt-linux-musl-gcc -dM -E - < /dev/null
to get the predefined macros explains this error
/usr/include/python2.7/pyconfig.h:83:5: error: #error unknown multiarch location for pyconfig.h # error unknown multiarch location for pyconfig.h
but I'm unsure about what I could do about it. It looks more like an uncovered case.
-
You compiler invocation looks a bit mistaken - you appear to be pointing it at directories for the hosting system rather than for your cross compilation target
For example, this kind of mix is something you want to never see:
In file included from /home/admin/source/staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl/include/stdarg.h:10:0, from /usr/include/libio.h:49,
You want it looking only at the musl includes for the omega2, not those of the hosting system in /usr/include. Given that it seems to have found some musl files, perhaps your compiler is built with the staging directory knowledge wrapped in, in which case you wouldn't have to specify any system includes. If you did have to specify one, it would probably be for the staging directory's target folder.
-
@Chris-Stratton Right, without specifying the include flags I get an error about
Python.h
not being found and it's nowhere in the staging directory.
-
@Gabriel-Gabor said in Cross-compile python packge:
@Chris-Stratton Right, without specifying the include flags I get an error about
Python.h
not being found and it's nowhere in the staging directory.Well, you can't point it at the host /usr/include, as in so doing you break most everything else.
You'll have to find the python includes for the target and point it at that.
If you configure your system build to actually build the version of python you want to use, you'd presumably have the includes. I'm not sure if they'd all be there on a the board itself, if they are you could potentially extract them back and put them somewhere.