Linking and running 32 bit .o lib file in Verdin iMX8M Mini

Hi Costa,

Somehow pervious ticket is closed. Could please answer this?

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/libARasSrv.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

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 message. I’ll help clarify your questions regarding Torizon OS, the i.MX8M Mini, and your 32-bit build issue.


1. Is Torizon OS 32-bit Available for i.MX8M Mini?

The Verdin iMX8M Mini module is based on a 64-bit ARM Cortex-A53 core (arm64/aarch64). According to the official Torizon documentation, Torizon OS for this module is provided as a 64-bit (arm64) operating system only. There is no official 32-bit (armhf/arm32) Torizon OS image available for the Verdin iMX8M Mini.


2. Your Problem: Linking 32-bit Libraries

You are trying to link 32-bit static libraries (libMaster.a and libRasSrv.a) but your application is being built as a 64-bit binary, or with the 64-bit (aarch64-linux-gnu-g++) toolchain. This is confirmed by errors like:

skipping incompatible src/SDK/LIB/Linux/aarch32/libMaster.a when searching for -l:libMaster.a

A 64-bit linker cannot use 32-bit libraries—this is an architecture incompatibility.


3. Solutions & Alternatives

Option 1: Build the Application as 32-bit

  • You can build a 32-bit (armhf) user application and run it on 64-bit Torizon OS, thanks to multiarch support (as long as all 32-bit dependencies are present).
  • However, your base system (kernel and OS) will still be 64-bit; only the container and the user application will run as 32-bit.

Steps:

  1. Change the build container and toolchain to ARM 32-bit:
    • Use arm-linux-gnueabihf-g++ for compiling and linking.
    • Set IMAGE_ARCH=arm in your Docker build arguments.
  2. Change the Docker base image for 32-bit:
    FROM --platform=linux/arm torizon/debian:$BASE_VERSION
    
  3. Install armhf libraries inside the container:
    • Keep the dpkg --add-architecture armhf
    • Install your runtime (and SDK) libraries as :armhf
  4. Make sure the Makefile uses the 32-bit toolchain and flags.

Caveats:

  • Some 32-bit binaries may need additional libraries (libc6:armhf, etc.) and possibly QEMU for running on an x86 build server.
  • On the target device, 64-bit Torizon OS has multiarch enabled, but you must install the 32-bit ARM libraries needed by your application inside the container.

Reference:


Option 2: Obtain (or Build) 64-bit Versions of Your Libraries

  • If possible, rebuild or get the libMaster.a and libRasSrv.a libraries as aarch64/arm64 binaries.
  • This allows linking with your 64-bit application, which is the native format for the Verdin iMX8M Mini and Torizon OS.

Option 3: Mixing 32-bit and 64-bit code

  • Directly linking 32-bit static libraries into a 64-bit program is not possible.
  • If the library source is unavailable, running your application as a 32-bit binary (Option 1 above) is your only route.

Practical Steps for Your Dockerfile

Update your build arguments and use the correct container/toolchain for 32-bit ARM:

ARG IMAGE_ARCH=arm
FROM torizon/debian-cross-toolchain-armhf:$CROSS_SDK_BASE_TAG AS build

# Add 32-bit architecture and install toolchain
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/*

# In your makefile, ensure CC is arm-linux-gnueabihf-g++

When building the image, set the architecture parameter to arm:

docker build --build-arg IMAGE_ARCH=arm ...

And inside your Dockerfile for the deployment stage, use:

FROM --platform=linux/arm torizon/debian:$BASE_VERSION AS deploy

Summary:

  • Torizon OS for iMX8M Mini is only available as 64-bit.
  • You can run 32-bit user applications (in containers) if you use multiarch and build the container/application as 32-bit (Option 1 above).
  • You cannot directly link 32-bit static libraries in a 64-bit build—match the application and library architectures.

For reference:

If you need example Dockerfiles/build scripts, let me know the exact step where you’re stuck, and I’ll be happy to provide more detail!

Best regards,
Toradex AI Assistant.

Hi @Jai8877,

We closed your first ticket because you made another one here with the same question. Please don’t open the same issue twice, as it makes it harder for other users with the same issue to find relevant information.

I’ll be closing this ticket as well and continue investigating your previous one.

Best regards,