Linking 32 bit .o lib file in Verdin iMX8M Mini

Hi Costa,
Hi Team,

I am using Verdin iMX8M Mini. I need compile 32 bit library in project. How to do this? I am using torizoncore builder . Here how to use multilib option in torizoncore builder.

I tried in dockerfile.

I would like know Torizon OS 32bit is available for IMX8M mini? and I am trying run using task runner with run-container-torizon-release-arm64.

My docker file contains:

build ------------------------------------------------------------------------
FROM commontorizon/debian-cross-toolchain-${IMAGE_ARCH}:${CROSS_SDK_BASE_TAG} AS build

ARG APP_ROOT
ARG IMAGE_ARCH=aarch64

RUN dpkg --add-architecture armhf &&
apt-get update &&
apt-get install -y --no-install-recommends
libc6:armhf
libstdc++6:armhf
libgcc-s1:armhf
gcc-arm-linux-gnueabihf
g+±arm-linux-gnueabihf &&
apt-get clean && rm -rf /var/lib/apt/lists/*

#deps
RUN apt-get -q -y update &&
apt-get -q -y install
#DO NOT REMOVE THIS LABEL: this is used for VS Code automation
#torizon_packages_build_start
#torizon_packages_build_end
#DO NOT REMOVE THIS LABEL: this is used for VS Code automation
&&
apt-get clean && apt-get autoremove &&
rm -rf /var/lib/apt/lists/*
#deps
COPY ./includes ${APP_ROOT}
COPY . ${APP_ROOT}
USER root
WORKDIR ${APP_ROOT}

#Remove the code from the debug builds, inside this container, to build the
release version from a clean build
RUN rm -rf ${APP_ROOT}/build-${IMAGE_ARCH}

#Compile the application
RUN if [ “$IMAGE_ARCH” = “arm64” ] ; then
make ARCH=${IMAGE_ARCH} CC=aarch64-linux-gnu-g++ CXXFLAGS=“-DEC_ARCH=EC_ARCH_ARM64” ;
elif [ “$IMAGE_ARCH” = “arm” ] ; then
make ARCH=${IMAGE_ARCH} CC=arm-linux-gnueabihf-g++ ;
elif [ “$IMAGE_ARCH” = “amd64” ] ; then
make ARCH=${IMAGE_ARCH} CC=x86_64-linux-gnu-g++ ;
fi

build ------------------------------------------------------------------------

deploy -----------------------------------------------------------------------
FROM --platform=linux/${IMAGE_ARCH} commontorizon/debian:${BASE_VERSION} AS deploy

ARG IMAGE_ARCH
ARG APP_ROOT

RUN apt-get -y update && apt-get install -y --no-install-recommends
#DO NOT REMOVE THIS LABEL: this is used for VS Code automation
#torizon_packages_prod_start
#torizon_packages_prod_end
#DO NOT REMOVE THIS LABEL: this is used for VS Code automation
&& apt-get clean && apt-get autoremove && rm -rf /var/lib/apt/lists/*

in my makefile its like:

Compiler and flags
CC := g++
CCFLAGS := -I/includes -std=c++14
#CXXFLAGS := -DEC_ARCH=EC_ARCH_ARM64
CXXFLAGS := -DEC_ARCH=EC_ARCH_ARM64
DBGFLAGS := -g
LDFLAGS := -Lsrc/SDK/LIB/Linux/aarch32
-l:libMaster.a
-l:libRasSrv.a

libMaster.a 32bit library
libRasSrv.a 32bit library

Output:

-Lsrc/SDK/LIB/Linux/aarch32 -l:libMaster.a -l:libRasSrv.a
91.19 /usr/lib/gcc-cross/aarch64-linux-gnu/12/…/…/…/…/aarch64-linux-gnu/bin/ld: skipping incompatible src/SDK/LIB/Linux/aarch32/libMaster.a when searching for -l:libMaster.a
91.19 /usr/lib/gcc-cross/aarch64-linux-gnu/12/…/…/…/…/aarch64-linux-gnu/bin/ld: skipping incompatible src/SDK/LIB/Linux/aarch32/libMaster.a when searching for -l:libMaster.a
91.19 /usr/lib/gcc-cross/aarch64-linux-gnu/12/…/…/…/…/aarch64-linux-gnu/bin/ld: cannot find -l:libMaster.a: No such file or directory
91.19 /usr/lib/gcc-cross/aarch64-linux-gnu/12/…/…/…/…/aarch64-linux-gnu/bin/ld: skipping incompatible src/SDK/LIB/Linux/aarch32/libMaster.a when searching for -l:libMaster.a
91.19 /usr/lib/gcc-cross/aarch64-linux-gnu/12/…/…/…/…/aarch64-linux-gnu/bin/ld: skipping incompatible src/SDK/LIB/Linux/aarch32/libMaster.a when searching for -l:libMaster.a
91.19 /usr/lib/gcc-cross/aarch64-linux-gnu/12/…/…/…/…/aarch64-linux-gnu/bin/ld: skipping incompatible src/SDK/LIB/Linux/aarch32/libRasSrv.a when searching for -l:libRasSrv.a
91.19 /usr/lib/gcc-cross/aarch64-linux-gnu/12/…/…/…/…/aarch64-linux-gnu/bin/ld: skipping incompatible src/SDK/LIB/Linux/aarch32/libRasSrv.a when searching for -l:libRasSrv.a
91.19 /usr/lib/gcc-cross/aarch64-linux-gnu/12/…/…/…/…/aarch64-linux-gnu/bin/ld: cannot find -l:libRasSrv.a: No such file or directory
91.19 /usr/lib/gcc-cross/aarch64-linux-gnu/12/…/…/…/…/aarch64-linux-gnu/bin/ld: skipping incompatible src/SDK/LIB/Linux/aarch64/libRasSrv.a when searching for -l:libRasSrv.a
91.19 /usr/lib/gcc-cross/aarch64-linux-gnu/12/…/…/…/…/aarch64-linux-gnu/bin/ld: skipping incompatible src/SDK/LIB/Linux/aarch32/libARasSrv.a when searching for -l:libRasSrv.a

How to compile this 32bit library?

Hi, I’m the Toradex AI Assistant.

I might make mistakes. Our support team will step in if needed. If I answered your question, please tick the “Solution” checkbox. For follow-up questions to me, please use @ToradexAI in your post.

Did you like my answer? :+1: :-1:


Hello! Thank you for your detailed question regarding compiling 32-bit libraries on the Verdin iMX8M Mini with TorizonCore. Let’s address your main queries step by step:


1. Is there a 32-bit Torizon OS image for Verdin iMX8M Mini?

No, there is no dedicated 32-bit (Armv7) Torizon OS image for the Verdin iMX8M Mini. The Torizon OS for this module is 64-bit (aarch64/arm64) only, as per the architecture capabilities and official releases:
Torizon OS Downloads

However, the hardware (Cortex-A53) does support running and executing 32-bit Arm (armhf/armv7) user space binaries.


2. Can I compile and run 32-bit binaries/libraries on 64-bit Torizon OS?

Yes, you can. This is typically achieved via multilib support and running 32-bit (armhf) applications inside containers on a 64-bit (aarch64) operating system.


3. Why does your current build fail?

Your compilation is failing because you are using a 64-bit cross-compiler (aarch64-linux-gnu-g++) to link 32-bit libraries (libEcMaster.a, libAtemRasSrv.a). These libraries are compiled for 32-bit (armhf), so you must use a 32-bit cross-toolchain (arm-linux-gnueabihf-g++) for both compilation and linking.


4. How to build 32-bit binaries inside a container?

You can do this by ensuring that:

  • The container platform is set to linux/arm/v7.
  • You use the appropriate 32-bit (armhf) toolchain.
  • Your Makefile and Dockerfile are set up to use the right compiler.

Minimal Example Dockerfile Segment

FROM --platform=linux/arm/v7 debian:bullseye

RUN apt-get update && \
    apt-get install -y --no-install-recommends \
    build-essential \
    gcc-arm-linux-gnueabihf \
    g++-arm-linux-gnueabihf \
    libc6:armhf \
    libstdc++6:armhf \
    libgcc-s1:armhf \
    && apt-get clean && rm -rf /var/lib/apt/lists/*

ENV CC=arm-linux-gnueabihf-gcc
ENV CXX=arm-linux-gnueabihf-g++

# Continue with your build steps

You should also ensure your Makefile uses the correct compiler:

CC := arm-linux-gnueabihf-gcc
CXX := arm-linux-gnueabihf-g++

5. How to run 32-bit applications on the Verdin iMX8M Mini?

The 64-bit Torizon OS kernel supports running 32-bit (armhf) containers. Here is an example of running a 32-bit Debian Bullseye container:

docker run --rm -it --platform linux/arm/v7 arm32v7/debian:bullseye

To build your 32-bit application for deployment, use --platform=linux/arm/v7 in your Dockerfile and build command.


6. Does TorizonCore Builder support multilib?

TorizonCore Builder itself is not directly related to cross-compiling user applications, but rather to customizing Torizon OS images (for overlays, container pre-provisioning, etc.) (More info).
So, the multilib support must be handled within your application container’s Dockerfile, not via TorizonCore Builder options.


Summary of Steps

  • Use --platform=linux/arm/v7 in your Docker commands to ensure a 32-bit (armhf) environment.
  • Use armhf toolchains (arm-linux-gnueabihf-g++) throughout your build.
  • The Makefile and Dockerfile must consistently use the armhf toolchain and base images.
  • No need for a 32-bit Torizon OS—your 64-bit Torizon OS can run 32-bit containers.

If you follow these steps, you should be able to build and run your 32-bit applications and libraries smoothly on the Verdin iMX8M Mini.

For more resources, please check:

If you have further questions about the Dockerfiles or Makefile setup, let me know!

Best regards,
Toradex AI Assistant.

I am looking forward for your solution?

Hi @Jai8877 ,

From your Makefile,

CC := g++

Since the system is 64-bits, g++ will attempt to compile your program to 64-bits. You need to use a compiler for 32-bits specifically, such as arm-linux-gnueabihf-g++. The steps suggested by the AI look reasonable to me, please follow them and let me know if you have any trouble.

Best regards,