最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c++ - Cross Compile Python Library for arm-linux-gnueabihf - Stack Overflow

programmeradmin0浏览0评论

I have a project which creates an Python library based on C++ sources. I use cMake and swig for the project.

I'm able to build them for x64 Linux, where I install a Python environment with pyenv. cMake finds the right Python version and is able to link my library to it.

Now I try to setup the same for cross compiling to Python on armhf. Also here, I was able to install my build python environment. But when I try to cross compile Python for armhf, i get the error: ./Modules/posixmodule.c:6399:11: error: array size missing in 'os_sched_param__doc__'

My environments variables are:

export ARCH="armhf"
export CC="arm-linux-gnueabihf-gcc"
export CXX="arm-linux-gnueabihf-g++"
export CFLAGS="-std=c99 -mhard-float -march=armv7-a -mfloat-abi=hard -mfpu=vfpv3 -mthumb-interwork -Wall -Wextra -pedantic -Wno-unknown-pragmas -Wno-psabi -Wno-long-long -Wno-variadic-macros -fno-strict-aliasing"
export CXXFLAGS="-mhard-float -march=armv7-a -mfloat-abi=hard -mfpu=vfpv3 -mthumb-interwork -Wall -Wextra -pedantic -Wno-unknown-pragmas -Wno-psabi -Wno-long-long -Wno-variadic-macros -fno-strict-aliasing"
export LDFLAGS="-Wl,--disable-new-dtags,-rpath,$ORIGIN"

The configuration command which I used is:

`./configure --prefix=/python/3.8.20-armhf --host=arm-linux-gnueabihf --build=x86_64-linux-gnu --without-ensurepip ac_cv_buggy_getaddrinfo=no ac_cv_file__dev_ptmx=yes ac_cv_file__dev_ptc=no --enable-optimizations`

And when calling make, the error shown above is returned. Is something wrong with my setup? Or with the steps which i try to cross compile the python sources?

If some better solutions are available to cross compile my python library for armhf, please let me know.

Edit 2025.03.14: Here is a bigger snipped of the build error:

arm-linux-gnueabihf-gcc -fno-strict-aliasing -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -std=c99 -mhard-float -march=armv7-a -mfloat-abi=hard -mfpu=vfpv3 -mthumb-interwork -Wall -Wextra -pedantic -Wno-unknown-pragmas -Wno-psabi -Wno-long-long -Wno-variadic-macros -fno-strict-aliasing -std=c99 -mhard-float -march=armv7-a -mfloat-abi=hard -mfpu=vfpv3 -mthumb-interwork -Wall -Wextra -pedantic -Wno-unknown-pragmas -Wno-psabi -Wno-long-long -Wno-variadic-macros -fno-strict-aliasing  -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration  -I./Include/internal  -I. -I./Include   -fPIC -DPy_BUILD_CORE_BUILTIN  -DPy_BUILD_CORE_BUILTIN -I./Include/internal -c ./Modules/posixmodule.c -o Modules/posixmodule.o
In file included from ./Include/Python.h:64,
                 from ./Modules/posixmodule.c:27:
./Modules/posixmodule.c:6399:11: error: array size missing in 'os_sched_param__doc__'
 6399 | PyDoc_VAR(os_sched_param__doc__);
      |           ^~~~~~~~~~~~~~~~~~~~~
./Include/pymacro.h:70:43: note: in definition of macro 'PyDoc_VAR'
   70 | #define PyDoc_VAR(name) static const char name[]
      |                                           ^~~~
./Modules/clinic/posixmodule.c.h:2879:1: warning: initializer-string for array of 'char' is too long
 2879 | "sched_param(sched_priority)\n"
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./Include/pymacro.h:73:24: note: in definition of macro 'PyDoc_STR'
   73 | #define PyDoc_STR(str) str
      |                        ^~~
./Modules/clinic/posixmodule.c.h:2878:1: note: in expansion of macro 'PyDoc_STRVAR'
 2878 | PyDoc_STRVAR(os_sched_param__doc__,
      | ^~~~~~~~~~~~
make: *** [Makefile:1914: Modules/posixmodule.o] Error 1
发布评论

评论列表(0)

  1. 暂无评论