Hi. I’m trying to build a test application for an adc, using IIO. I’m not sure if the way I’m building is up to date, as I’m doing it with a container and not with torizoncore-builder.
I have the following Dockerfile:
ARG CROSS_TC_IMAGE_ARCH=armhf
ARG CROSS_TC_DOCKER_REGISTRY=torizon
ARG BASE_NAME=debian
ARG IMAGE_ARCH=linux/arm/v7
ARG IMAGE_TAG=2-bullseye
ARG DOCKER_REGISTRY=torizon
# First stage, x86_64 build container
FROM $CROSS_TC_DOCKER_REGISTRY/debian-cross-toolchain-$CROSS_TC_IMAGE_ARCH:$IMAGE_TAG AS cross-container
ARG GCC_PREFIX=arm-linux-gnueabihf
# copy project source
WORKDIR /project
COPY src/ /project
# compile
RUN mkdir build \
&& cd build \
&& $GCC_PREFIX-gcc -Wall -D_GNU_SOURCE -Og -o test ../test.c -liio
# Second stage, container for target
FROM --platform=$IMAGE_ARCH $DOCKER_REGISTRY/$BASE_NAME:$IMAGE_TAG AS deploy-container
# get the compiled program from the Build stage
COPY --from=cross-container /project/build/* /usr/local/bin/
CMD ["test"]
And then I build the image with running:
$ docker build . --build-arg CROSS_TC_IMAGE_ARCH=arm64 --build-arg IMAGE_ARCH=linux/arm64 --build-arg GCC_PREFIX=aarch64-linux-gnu -t test
Build stage fails because the linker does not find iio:
/usr/lib/gcc-cross/aarch64-linux-gnu/10/../../../../aarch64-linux-gnu/bin/ld: cannot find -liio
collect2: error: ld returned 1 exit status
Of course, I could apt install libiio0
inside the container, but that installs the amd64 binaries.
Now, a bunch of questions:
- Do I have to compile the iio library inside the container to build the test image?
- Isn’t there any precompiled library to install or another image to use?
- Does the torizon image running on my board have the binaries of the iio library?