[Development] How to build 32-bit Qt with Qt6/CMake
Cristian Adam
cristian.adam at qt.io
Wed Nov 25 18:00:04 CET 2020
On my Ubuntu 20.04 x86_64 I've build Qt6Base x86 like this:
1. Upgrade the compiler:
sudo apt install g++-9-multilib
2. Install dev packages:
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install '^libxcb.*-dev:i386' libx11-xcb-dev:i386 libglu1-mesa-dev:i386 libxrender-dev:i386 libxi-dev:i386 libxkbcommon-dev:i386 libxkbcommon-x11-dev:i386
3.
Updated pkg-config for i386:
sudo apt-get install pkg-config-i686-linux-gnu
I'm not sure if step 3 is needed, since I haven't actually set PKG_CONFIG_LIBDIR later.
Configured Qt6 with this x86-toolchain.cmake file:
cmake_minimum_required(VERSION 3.11)
include_guard(GLOBAL)
set(CMAKE_PREFIX_PATH /usr/lib/i386-linux-gnu;/usr/lib32)
set(CMAKE_IGNORE_PATH /usr/lib/x86_64-linux-gnu)
include(CMakeInitializeConfigs)
set(QT_USE_DEFAULT_CMAKE_OPTIMIZATION_FLAGS ON)
function(cmake_initialize_per_config_variable _PREFIX _DOCSTRING)
if (_PREFIX MATCHES "CMAKE_(C|CXX|ASM)_FLAGS")
set(CMAKE_${CMAKE_MATCH_1}_FLAGS_INIT "-m32")
foreach (config DEBUG RELEASE MINSIZEREL RELWITHDEBINFO)
set(CMAKE_${CMAKE_MATCH_1}_FLAGS_${config}_INIT "-O0")
endforeach()
endif()
_cmake_initialize_per_config_variable(${ARGV})
endfunction()
Note that I haven't changed the CMAKE_SYSTEM_NAME which would trigger CMake into cross-compiling and then Qt requiring QT_HOST_PATH to be set.
Cheers,
Cristian.
________________________________
From: Development <development-bounces at qt-project.org> on behalf of Thiago Macieira <thiago.macieira at intel.com>
Sent: Wednesday, November 25, 2020 4:22 PM
To: development at qt-project.org <development at qt-project.org>
Subject: Re: [Development] How to build 32-bit Qt with Qt6/CMake
On Wednesday, 25 November 2020 05:16:58 PST Joerg Bornemann wrote:
> This looks correct so far. A small improvement would be to put all this
> into a CMake toolchain file and additionally do
> set(CMAKE_SYSTEM_NAME Linux)
>
> Then you can cross-build with -DCMAKE_TOOLCHAIN_FILE=x86-toolchain.cmake
>
> In a perfect world, your distro would have provided this file.
I checked both distros I use and neither does. I suppose CMake itself should
create the toolchain file for multilib builds on Linux if this is a common
occurrence, but seems not to be the case.
The only toolchain file I can find in my system are the ones inside the Zephyr
and Chromium source codes. In fact, the one in qtwebengine/src/3rdparty/
chromium/third_party/boringssl/src/util/32-bit-toolchain.cmake is nearly
perfect.
What is the one generated in qtbase/lib/cmake/Qt6/qt.toolchain.cmake for?
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel DPG Cloud Engineering
_______________________________________________
Development mailing list
Development at qt-project.org
https://lists.qt-project.org/listinfo/development
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20201125/78958dc1/attachment-0001.html>
More information about the Development
mailing list