2

I have a ARM virtual machine on AWS with Ubuntu18.04 installed.

dpkg & uname commands show this,

$ dpkg --print-architecture
arm64
$ uname -m
aarch64

I've got a third-party precompiled static library (.a) built for 32-bit.

I understand that I cannot link 32-bit library to a 64-bit application, so I've created a new application which will link the library and get compiled for 32-bit. This application will communicate with rest of the applications (64-bit) using some IPC mechanism. To compile this application I've added following flag in my cmake file,

set (CMAKE_CXX_FLAGS "-m32")

but the compiler throw this error,

c++: error: unrecognized command line option ‘-m32’

c++ version on my machine is,

$ c++ -v
Using built-in specs.
COLLECT_GCC=c++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/aarch64-linux-gnu/7/lto-wrapper
Target: aarch64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 7.4.0-1ubuntu1~18.04.1' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=aarch64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --enable-multiarch --enable-fix-cortex-a53-843419 --disable-werror --enable-checking=release --build=aarch64-linux-gnu --host=aarch64-linux-gnu --target=aarch64-linux-gnu
Thread model: posix
gcc version 7.4.0 (Ubuntu/Linaro 7.4.0-1ubuntu1~18.04.1)

It shows that it is prepared with configuration option --enable-multiarch which I suppose should allow me to compile for different architecture (32-bit ARM).

On one of the other thread on stackoverflow says that some ARM64 machine's hardware may not support compilation of 32-bit applications.

My question is how to check if my ARM64 machine is capable of building 32-bit application? And if it is capable of building then what is the alternative to -m32 flag?

Jeff Schaller
68.8k35 gold badges122 silver badges263 bronze badges
asked Jan 9, 2020 at 7:25

1 Answer 1

2

I resolved this issue by using different toolchains for compiling 32bit and 64bit applications - arm-linux-gnueabihf & arm-linux-gnueabi respectively. Not sure if there exist a better way of doing it.

Anyways, I don't need this anymore as the Cavium processor of the ARM64 machine I'm using does not support 32bit libraries. I will have to find a way to get the 64bit version of the library.

answered Jan 13, 2020 at 12:07

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.