Cross compile problem: #include <Python.h> and -lpython2.7
-
I have successfully installed python on my omega2+ and run python code there. I have successfully built the cross compiler tools and can compile C/C++ code for my omega2+.
However, I have some C++ code that calls the python C++ API. It needs to #include <Python.h> when compiling and needs to link to -lpython2.7. The cross compiler finds my host system Python.h which ultimately leads to compile #error "Unknown word size". Also, libpython2.7.so doesn't exist in my cross compile tool chain.
Has anyone gone down this path before that can offer a recommendation on how to setup my cross compiler tool chain to handle this?
(If anyone is curious, the code I'm attempting to compile is a UAV autopilot ... I'm evaluating the feasibility of flying the omega2+ on board my aircraft.) Project code (fully open-source) is here for anyone that wants to browse it: https://github.com/AuraUAS/aura-core
Thanks in advance,
Curt.
-
Ok, I'll reply to myself here because I think I found a solution.
- Download python-2.7.13 source code and extract it.
- Run configure with all the options needed by the LEDE cross compile tools
- Run make and the compile ran to successful completion.
- make install failed miserably because of some pc host vs. omega stuff that was beyond me to figure out.
- manually copied the Include tree from python src to ...source/staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl/include/python2.7/ and manually copied the pyconfig.h file as well.
- manually copied the libpython2.7.a file to ...source/staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl/lib/
- fiddled with the build system in my own software because autoconf couldn't run python-config and get the right answer.
- compiled my code successfully.
All that's left is it test run in on the actual omega2 which I will hopefully be able to do this weekend.