fatal error: sys/cdefs.h: No such file or directory

Hi,
I am new to openBalena. Following guide here, I successfully deploy myApp for raspberry pi3(32 bit) on ubuntu 64 bit.

Then I tried to deploy a Kivy app using the Dockerfile below.

FROM andrewmk/rpi-kivy:stretch
RUN apt-get update && apt-get install -y build-essential python3-pip python3-setuptools python3-dev && apt-get clean && rm -rf /var/lib/apt/lists/
RUN pip3 install paho-mqtt && pip3 install wheel && pip3 install pgen && pip3 install -I Cython==0.28.2 && rm -Rf /root/.cache/

RUN git clone -b 1.10.1 --depth 1 https://github.com/kivy/kivy && cd kivy && python3 setup.py build && python3 setup.py install && cd …
RUN mkdir -p apps
COPY ./apps/ ./apps/
CMD [“python3”, “apps/pictures/main.py”]\

When compiling, it says below:

[Build] main running build_ext
[Build] main Build configuration is:
[Build] main * use_rpi = 1
[Build] main * use_mali = 0
[Build] main * use_egl = 0
[Build] main * use_opengl_es2 = 1
[Build] main * use_opengl_mock = 0
[Build] main * use_sdl2 = 0
[Build] main * use_ios = 0
[Build] main * use_mesagl = 0
[Build] main * use_x11 = 0
[Build] main * use_wayland = 0
[Build] main * use_gstreamer = 0
[Build] main * use_avfoundation = 0
[Build] main * use_osx_frameworks = 0
[Build] main * debug_gl = 0
[Build] main * debug = False
[Build] main Updated build/lib.linux-armv6l-3.5/kivy/include/config.h
[Build] main Updated kivy/include/config.h
[Build] main Updated build/lib.linux-armv6l-3.5/kivy/include/config.pxi
[Build] main Updated kivy/include/config.pxi
[Build] main Updated build/lib.linux-armv6l-3.5/kivy/setupconfig.py
[Build] main Updated kivy/setupconfig.py
[Build] main Detected compiler is unix
[Build] main cythoning kivy/graphics/vertex.pyx to kivy/graphics/vertex.c
[Build] main building ‘kivy.graphics.vertex’ extension
[Build] main creating build/temp.linux-armv6l-3.5
[Build] main creating build/temp.linux-armv6l-3.5/kivy
[Build] main creating build/temp.linux-armv6l-3.5/kivy/graphics
[Build] main arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-6waWnr/python3.5-3.5.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Ikivy/include -Ikivy/include -I/usr/include/python3.5m -c kivy/graphics/vertex.c -o build/temp.linux-armv6l-3.5/kivy/graphics/vertex.o
[Build] main In file included from /usr/include/limits.h:25:0,
[Build] main from /usr/lib/gcc/arm-linux-gnueabihf/6/include-fixed/limits.h:168,
[Build] main from /usr/lib/gcc/arm-linux-gnueabihf/6/include-fixed/syslimits.h:7,
[Build] main from /usr/lib/gcc/arm-linux-gnueabihf/6/include-fixed/limits.h:34,
[Build] main from /usr/include/python3.5m/Python.h:11,
[Build] main from kivy/graphics/vertex.c:4:
[Build] main /usr/include/features.h:364:25: fatal error: sys/cdefs.h: No such file or directory
[Build] main # include <sys/cdefs.h>
[Build] main ^
[Build] main compilation terminated.
[Build] main /usr/lib/python3.5/distutils/dist.py:261: UserWarning: Unknown distribution option: ‘extra_requires’
[Build] main warnings.warn(msg)
[Build] main /usr/lib/python3.5/distutils/dist.py:261: UserWarning: Unknown distribution option: ‘install_requires’
[Build] main warnings.warn(msg)
[Build] main /usr/lib/python3.5/distutils/dist.py:261: UserWarning: Unknown distribution option: ‘setup_requires’
[Build] main warnings.warn(msg)
[Build] main /usr/lib/python3.5/distutils/dist.py:261: UserWarning: Unknown distribution option: ‘dependency_links’
[Build] main warnings.warn(msg)
[Build] main error: command ‘arm-linux-gnueabihf-gcc’ failed with exit status 1
[Build] Built 1 service in 8:01
[Error] Deploy failed\

After some google search fatal error: sys/cdefs.h: No such file or directory|

Tried install libc6-dev-i386 and g+±multilib, but still have no luck.

The Dockerfile was tested on a rpi3(32 bit) with docker and it did work.

So I have no idea now. Could you please help? Thank you.

Hi,

I can build your Dockerfile on emulated environment without any problems so it’s weird if it doesn’t work on your side.
Since you’re cross-building an ARM image on Ubuntu 64 bit host, can you please make sure QEMU is installed on your host and try again?

Hi,

Thank you for the reply. I didn’t install QEMU additionally, but when I run

balena deploy myApp --logs --source . --emulated

I noticed

main Step 2/8 : COPY [".balena/qemu-execve","/tmp/qemu-execve"]

So does this mean QEMU exist?

If run

file .balena/qemu-execve

get

.balena/qemu-execve: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked

And for the example sense-snake, I deployed successfully in the same way.

The balena-cli downloads and injects QEMU on demand and apparently it’s correctly used during the build. Pip however is a bit notorious and can’t always build native extensions/modules via an emulation layer. It does look to me this is the case here, which if I’m right, is a bit unfortunate as I don’t know of any workarounds. It won’t help with deployment, but you can use local mode to develop (which builds on the device instead of locally on your computer), then somehow copy the produced image and deploy it directly.

OK, thank you. I will try local mode.

Also, I’m thinking if creating a new docker image with all requirements installed will work.

Hi
I believe it would depend on where you are building this image. If you are building it on an Arm host natively, there shouldn’t be any issue with it building an image with the required packages installed. Do let us know if it works out for you using pip on a native build.

Hi,
I have tried deploying the example sense-snake app on a raspberry3, but stuck at

main standard_init_linux.go:211: exec user process caused “exec format error”

My client version is 11.21.5 on the rpi3, on the ubuntu it’s 11.20.1.

Hey there.

main standard_init_linux.go:211: exec user process caused “exec format error”

That sounds like trying to run a binary compiled for the wrong system/architecture. Do you get this at runtime? At which point?