Building Qt for QNX

Setting up QNX SDP

Building Qt 6 requires downloading and installing of QNX SDP 7.1 from the QNX website .

注意: A suitable license is required. Contact QNX 了解更多信息。

The compiler and other parts of the tool chain are provided in the SDP packages. Initialize your build environment by running the QNX setup script from your SDP installation folder in a terminal, like so:

source qnxsdp-env.sh
					

Host build

The cross-compiling Qt requires a host build of Qt being available. During the build, tools such as moc , rcc , qmlcachegen , qsb , are invoked from there. You can either build Qt from sources for the host or install host build using online installer. However, it is advisable to ensure that you can build Qt for the desktop target on the host as well. For more detailed information please see Cross-compiling Qt .

Creating a toolchain file for QNX

To cross-compile a project with CMake a toolchain file is needed. This CMake-language file sets the right values for the platform name, compiler/linker, and many other toolchain-specific things. A minimal toolchain file can be found from CMake documentation:

set(CMAKE_SYSTEM_NAME QNX)
set(arch gcc_ntoarmv7le)
set(CMAKE_C_COMPILER qcc)
set(CMAKE_C_COMPILER_TARGET ${arch})
set(CMAKE_CXX_COMPILER q++)
set(CMAKE_CXX_COMPILER_TARGET ${arch})
set(CMAKE_SYSROOT $ENV{QNX_TARGET})
					

The arch variable can be set to either gcc_ntoarmv7le , gcc_ntoaarch64le or gcc_ntox86_64 , depending on your target architecture.

Configuring and building Qt for QNX

Assuming the following:

  • The toolchain file is called qnx.cmake and is located in $HOME .
  • The Qt repository checked out, at minimum the qtbase module, under $HOME/qt .
  • A host build of Qt in $HOME/qt-host .
  • The installation location on the local system will be $HOME/qnx-install .

After creating and switching to the build directory run:

cmake -GNinja -DCMAKE_TOOLCHAIN_FILE=$HOME/qnx.cmake  \
-DQT_HOST_PATH=$HOME/qt_host \
-DCMAKE_INSTALL_PREFIX=$HOME/qnx_install \
$HOME/qt
					

Once configuration completes without errors,build by running:

cmake --build . --parallel
					

Once built, run:

cmake --install .
					

Which will install the results to $HOME/qnx_install .

You can also configure Qt with the configure tool. Since Qt 6, this tool is a wrapper around CMake.

Third party libraries

Make sure that your system image contains the following additional 3rd-party libraries which are not always included in minimal QNX Neutrino RTOS images:

  • libfontconfig
  • libfreetype
  • libiconv
  • libicui18n
  • libicudata
  • libicuuc
  • libpng14
  • libxml2
  • libsqlite3
  • libssl
  • libcrypto

注意: This is not a complete list of shared libraries used by Qt on QNX Neutrino OS. Multiple shared libraries are already available in a typical OS image, or included by other parts of the system, for example Screen .

另请参阅 Qt 配置选项 and Configuring Qt .