Building cython based module with numpy dependency in SDK
A message that is not in the archive (sent off-list or not yet received): [email protected]
Ok, so I think I found the solution to my problem.
In distutils3.bbclass, last line, LDSHARED is set to "${CCLD} -shared". That environment variable is not set after sourcing the env-setup script from my SDK.
My workaround is to check for some environment vars that is set and manually set it in my setup.py since my module will only be used on this platform and on developer computers anyway. It feels like the correct thing to do would be to set LDSHARED when sourcing the SDK setup script.
BR
/Einar
Quoted 62 lines · Einar Vading via lists.yoctoproject.org
Hello!
I've been trying to build a python package which has a component written in c that is used through cython.
But when I try to build in the SDK I first got:
#error "
LONG_BITdefinition appears wrong for platform (bad gcc/glibc config?)."I figured it had to do with "-I/home/einar/tmp/sdk/poky/3.0.2/sysroots/x86_64-pokysdk-linux/usr/lib/python3.7/site-packages/numpy/core/include" since that points to my native sysroot instead of the target sysroot.
So I added:
numpy_incdir=numpy.get_include()python_incdir= '.' # Just some harmeless directory try:
native = os.environ['OECORE_NATIVE_SYSROOT'] target = os.environ['OECORE_TARGET_SYSROOT']
except KeyError:
pass
else:
rel_path= Path(numpy_incdir).relative_to(native)numpy_incdir= target /rel_pathpython_incdir= target + '/usr/include/python3.7m/'to my
setup.pyand got passed the first compiler error.So now my extension module is built ok but after that there is a step that fails:
creating build/lib.linux-x86_64-3.7 x86_64-pokysdk-linux-gcc -shared -Wl,-O1 -L -Wl,-O1 -Wl,-O1
(quoted diff) +0
-2-Wl,--hash-style=gnu -Wl,--as-needed -fstack-protector-strong -Wl,-z,relro,-z,now -O2 -pipe -g -feliminate-unused-debug-types
build/temp.linux-x86_64-3.7/myext.obuild/temp.linux-x86_64-3.7/extlib.obuild/temp.linux-x86_64-3.7/myextmodule.o(quoted diff) +0
-2-L/home/einar/tmp/poky/3.0.2/sysroots/x86_64-pokysdk-linux/usr/lib -lpython3.7m -obuild/lib.linux-x86_64-3.7/bbfit.cpython-37m-x86_64-linux-gnu.so -lm unable to execute 'x86_64-pokysdk-linux-gcc': No such file or directory
error: command 'x86_64-pokysdk-linux-gcc' failed with exit status 1And I can't get passed this error and I think it's weird that it's trying to use x86_64-pokysdk-linux-gcc since my extension module is built with
CC=arm-poky-linux-gnueabi-gcc -mthumb -mfpu=neon-vfpv4
(quoted diff) +0
-3-mfloat-abi=hard -mcpu=cortex-a7 -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/home/einar/tmp/poky/3.0.2/sysroots/cortexa7t2hf-neon-vfpv4-poky-linux-gnueabiShould building a cython extension in the SDK work? Any ideas why ming won't compile. Or why it's trying to use a compiler for host instead of target in the end?
Best regards,
Einar