[Development] How to build 32-bit Qt with Qt6/CMake
Thiago Macieira
thiago.macieira at intel.com
Tue Nov 24 21:32:31 CET 2020
Like the "How to build unit tests & examples on demand with Qt6/CMake?"
thread, now I need to build a 32-bit build of Qt but I don't know how.
TL;DR:
need to set PKG_CONFIG_LIBDIR in the environment and pass to cmake:
-DCMAKE_ASM_FLAGS=-m32
-DCMAKE_C_FLAGS=-m32\ -O0
-DCMAKE_CXX_FLAGS=-m32\ -O0
-DCMAKE_PREFIX_PATH=/usr/lib32
Is this the correct solution? Is there a better way?
I've done this:
A) try a 64-bit build
1) cmake [some arguments for 64-bit]
2) ninja
3) confirm everything built just fine
B) attempt a 32-bit build
1) cmake [exactly same arguments] \
-DFEATURE_gui=OFF -DCMAKE_C_FLAGS=-m32\ -O0 -DCMAKE_CXX_FLAGS=-m32\ -O0
2) ninja tst_thetest
Fails with:
: && /home/tjmaciei/bin/g++ -m32 -O0 -g -Wl,--gc-sections src/tools/rcc/
CMakeFiles/rcc.dir/main.cpp.o src/tools/rcc/CMakeFiles/rcc.dir/rcc.cpp.o -o
bin/rcc -Wl,-rpath,:::::::::::::: src/tools/bootstrap/libBootstrap.a
/usr/lib64/libzstd.so -lpthread /usr/lib32/libz.so && :
/usr/bin/ld: /usr/lib64/libzstd.so: error adding symbols: file in wrong format
Note how the path to libzstd is wrong. The CMake output had this:
-- Found ZLIB: /usr/lib32/libz.so (found suitable version "1.2.11.1", minimum
required is "1.0.8")
-- Found ZSTD: /usr/lib64/libzstd.so (found suitable version "1.4.5", minimum
required is "1.3")
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.2")
-- Found WrapDBus1: /usr/lib32/libdbus-1.so (found suitable version "1.12.20",
minimum required is "1.2")
/usr/lib32/libzstd.so does exist.
3) rm -rf *; cmake [same as above but add] -DCMAKE_PREFIX_PATH=/usr/lib32
...
-- Found ZLIB: /usr/lib32/libz.so (found suitable version "1.2.11.1", minimum
required is "1.0.8")
-- Found ZSTD: /usr/lib32/libzstd.so (found suitable version "1.4.5", minimum
required is "1.3")
...
-- Found WrapSystemPCRE2: /usr/lib64/libpcre2-16.so (found suitable version
"10.35", minimum required is "10.20")
4) ninja tst_thetest
Fails during QtCore linking:
/usr/bin/ld: /usr/lib64/libpcre2-16.so: error adding symbols: file in wrong
format
There is no 32-bit pcre2-16.
5) rm -rf *;
export PKG_CONFIG_LIBDIR=/usr/lib32/pkgconfig:/usr/share/pkgconfig;
cmake [as above with -DCMAKE_PREFIX_PATH]
-- Using Qt bundled PCRE2.
-- Found WrapPCRE2: TRUE
-- Could NOT find WrapSystemPCRE2 (missing: PCRE2_LIBRARIES __pcre2_found)
(Required is at least version "10.20")
6) ninja tst_thetest
Fails during QtCore linking:
/usr/bin/ld: i386:x86-64 architecture of input file `src/corelib/CMakeFiles/
Core.dir/global/minimum-linux.S.o' is incompatible with i386 output
7) rm -rf *;
export PKG_CONFIG_LIBDIR=/usr/lib32/pkgconfig:/usr/share/pkgconfig;
cmake [as above with -DCMAKE_PREFIX_PATH] -DCMAKE_ASM_FLAGS=-m32
8) ninja tst_thetest
Success
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel DPG Cloud Engineering
More information about the Development
mailing list