Deploying Kanzi applications to QNX

Before you can build a Kanzi application for your target platforms, set up and configure the Kanzi build environment for your target platforms. The build environment includes tools that the Kanzi build system uses to build your application for your target platforms.

The Kanzi QNX platform packages are available on request.

Requirements

To build and deploy Kanzi applications to QNX, you need:

  • QNX software development platform.

    Library requirements from the QNX software development platform:

    • slog2

    You can get the QNX development tools at https://blackberry.qnx.com.

  • For SCons-based platform package:

    • For SCons 2.5.1 to 3.1.2, Python 2.7.

    • For SCons 3.0.0 to 3.1.2, Python 2.7, or Python 3.5 or newer.

    • For SCons 4.0.0 to 4.2.0, Python 3.5 or newer.

    • For SCons 4.3.0 or newer, Python 3.6 or newer.

  • For Cmake-based platform package: CMake 3.21 and Ninja 1.10.x

Before deploying your Kanzi application to your QNX target device, make sure that device is running the QNX Screen service. See http://www.qnx.com/developers/docs/7.0.0/index.html#com.qnx.doc.screen/topic/manual/cscreen_about.html.

Supported build systems, STDLIB implementation, and library linking

Kanzi platform packages support these build systems:

  • SCons. Note that this platform package name does not contain SCons in its name.

    When you extract this platform package, you can find it in the Engine/configs/platforms/<QNX platform version> directory.

    The platform package contains the SConstruct and config.py files.

  • CMake. Note that this platform package contains -cmake in its name.

    When you extract this platform package, you can find it in the Engine/cmake/toolchains/<QNX platform version>.

    The platform package contains the <QNX platform version>.cmake file that lists the CMake options used to create it.

Kanzi offers QNX platform packages that are based on these STDLIB implementations:

  • LLVM. You can recognize this implementation by the _cxx or -cxx in the name of the platform package archive.

    When you build applications with this package, use the:

    • SCons flag --stdlib=qnx

    • CMake define -DKANZI_QNX_STDLIB=qnx

  • GNU. CMake-based platform packages explicitly mention gpp in the name of the platform package archive.

    When you build applications with this package, use the:

    • SCons flag --stdlib=gnu

    • CMake define -DKANZI_QNX_STDLIB=gnu

Kanzi platform packages support these library linking options:

  • Static. There is no scons flag as it is the default option.

    To build an application with statically linked libraries, use the CMake define -DKANZI_BUILD_SHARED_LIBS:BOOL=OFF.

  • Dynamic.

    To build an application with dynamically linked libraries, use the:

    • SCons flag --dynamic

    • CMake define -DKANZI_BUILD_SHARED_LIBS:BOOL=ON

Building Kanzi applications for QNX

Building Kanzi applications for QNX 7.1 using CMake

For example, to build the kzb_player application on Linux for QNX 7.1 using CMake:

  • With the LLVM STDLIB implementation, from a -cxx platform package, with the shared library linking:

    cd Engine/applications/kzb_player
    mkdir build
    cd build
    cmake -GNinja
          -DCMAKE_BUILD_TYPE=Release
          -DCMAKE_TOOLCHAIN_FILE=../../cmake/toolchains/qnx710-aarch64.cmake
          -DPLATFORM_BACKEND=qnx_screen
          -DCMAKE_INSTALL_PREFIX=../bin -DKANZI_QNX_STDLIB=qnx
          -DKANZI_BUILD_SHARED_LIBS:BOOL=ON
          -DKanzi_DIR=../../lib/cmake/Kanzi
          -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON ..
    cmake --build .
    cmake --install .
    
  • With the GNU STDLIB implementation, from a Non-cxx platform package:

    cd Engine/applications/kzb_player
    mkdir build
    cd build
    cmake -GNinja
          -DCMAKE_BUILD_TYPE=Release
          -DCMAKE_TOOLCHAIN_FILE=../../cmake/toolchains/qnx710-aarch64.cmake
          -DPLATFORM_BACKEND=qnx_screen
          -DCMAKE_INSTALL_PREFIX=../bin
          -DKANZI_QNX_STDLIB=gnu
          -DKanzi_DIR=../../lib/cmake/Kanzi
          -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON ..
    cmake --build .
    cmake --install .
    

Building Kanzi applications for QNX 7.0 using CMake

On some devices that support QNX 7.0 not all ES 3.2 features work correctly. To work around these issues, build Kanzi applications for GL_ES 3.1 with CMake using these defines:

  • -DKANZI_GLES_LINKED:STRING=31

  • -DKANZI_GLES_DLOAD:STRING=31

For example, to build the kzb_player application on Linux for QNX 7.0 using CMake:

  • With the LLVM STDLIB implementation, from a -cxx platform package, with dynamic library linking:

    cd Engine/applications/kzb_player
    mkdir build
    cd build
    cmake -GNinja
          -DCMAKE_BUILD_TYPE=Release
          -DCMAKE_TOOLCHAIN_FILE=../../cmake/toolchains/qnx700-aarch64.cmake
          -DPLATFORM_BACKEND=qnx_screen
          -DCMAKE_INSTALL_PREFIX=../bin
          -DKANZI_QNX_STDLIB=qnx
          -DKANZI_BUILD_SHARED_LIBS:BOOL=ON
          -DKANZI_GLES_LINKED:STRING=31
          -DKANZI_GLES_DLOAD:STRING=31
          -DKanzi_DIR=../../lib/cmake/Kanzi
          -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON ..
    cmake --build .
    cmake --install .
    
  • With the GNU STDLIB implementation, from a non-cxx platform package, with static library linking:

    cd Engine/applications/kzb_player
    mkdir build
    cd build
    cmake -GNinja
          -DCMAKE_BUILD_TYPE=Release
          -DCMAKE_TOOLCHAIN_FILE=../../cmake/toolchains/qnx700-aarch64.cmake
          -DPLATFORM_BACKEND=qnx_screen
          -DCMAKE_INSTALL_PREFIX=../bin
          -DKANZI_QNX_STDLIB=gnu
          -DKANZI_BUILD_SHARED_LIBS:BOOL=OFF
          -DKANZI_GLES_LINKED:STRING=31
          -DKANZI_GLES_DLOAD:STRING=31
          -DKanzi_DIR=../../lib/cmake/Kanzi
          -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON ..
    cmake --build .
    cmake --install .
    

Building Kanzi applications for QNX using SCons

SCons runs the SConstruct file in the configuration directory of the platform from which you run the scons command. SConstruct file is the entry point for building the application and contains the information about the Kanzi Engine location and runs these files:

  • <KanziWorkspace>/Engine/configs/platforms/common/config.py includes the Kanzi library definitions and common build flags used when building for all platforms.

  • <KanziWorkspace>/Engine/configs/platforms/<PlatformName>/config.py includes the Kanzi platform-specific build flags and defines, and the toolchain. Edit this file when you want to customize the build configuration for your platform. For example, to match the locations of your platform SDK and board support package.

  • <ProjectName>/Application/configs/platforms/common/config.py includes the optional, project-specific common configuration parameters.

  • <ProjectName>/Application/configs/platforms/<PlatformName>/config.py includes the optional, project-specific platform configuration parameters.

To build Kanzi applications for QNX using Scons:

  1. In Kanzi Studio select File > Open Kanzi Command Prompt and in the Kanzi Command Prompt in the configuration directory of the platform for which you want to build the Kanzi application (<ProjectName>/Application/configs/platforms/<PlatformName>).

    For example, to build your Kanzi application for Linux, open the Kanzi Command Prompt in the <ProjectName>/Application/configs/platforms/linux_x11_glx_cpp98 directory.

  2. Run the scons command with the build parameters for your Kanzi application.

    Syntax

    scons <library> <type> <name>

    Parameters

    library

    (Optional) the graphics library:

    • ES2 builds the application with OpenGL ES 2.0

    • ES3 builds the application with OpenGL ES 3.0

    type

    (Optional) the build type:

    • Release builds the application with compiler optimizations enabled. The release option builds smaller files than the debug option. Use this option for production purposes. Default value.

    • Debug builds the application with disabled compiler optimizations and contains full debug information you can use with a debugger. The debug option builds larger files and debug applications run slower. Use this option for development purposes.

    • Profiling builds the application with compiler optimizations enabled and links the application against the Profiling build. Use this option when you want to measure the performance of different parts of Kanzi Engine. For example, when you want to find out how much time Kanzi uses on different tasks during application startup, or which parts of the application take a lot of time to run. See Measuring application performance.

    name

    (Optional) the name of the project

    Examples

    // Builds the application with the default settings as specified
    // in config.py and SConstruct configuration files.
    scons
    
    // Builds the debug version of the application.
    scons debug
    
    // Builds the debug version of the application with the
    // OpenGL ES 3.0 graphics library from the |ks|
    // project named MyProject.
    scons ES3 debug MyProject
    

Scons builds the Kanzi application source code and binary files in the <ProjectName>/Application/output directory.

Deploying Kanzi applications to a QNX device

To deploy Kanzi applications to QNX:

  1. Build your Kanzi application for QNX. See Building Kanzi applications for QNX.

  2. Connect your QNX device to your computer.

  3. From the <ProjectName>/Application/output directory copy to your QNX target device:

    • Kanzi application exe file

    • kzb files that your Kanzi application uses

    • application.cfg file which contains a list of all the kzb files your Kanzi application uses

  4. On your QNX target device open the command line and add execution rights for your Kanzi application on that device:

    // Adds execution rights on the QNX target device
    // for the Kanzi application called MyApplication.
    chmod 755 MyApplication
    
  5. On the command line start the application on your QNX target device:

    // Starts the Kanzi application called MyApplication.
    ./MyApplication
    

Printing Screen display information

You can list QNX Screen display information for your Kanzi application.

To print Screen display information:

  1. Deploy your Kanzi application to QNX. See Deploying Kanzi applications to a QNX device.

  2. Run the application with the -enum-qnx-displays command-line argument:

    ./MyApplication -enum-qnx-displays
    

The application prints for each display this information and exits:

  • Display ID

  • Whether the display is attached

  • Whether the display is detachable

  • Whether the display is focused

  • Current resolution of the display

  • (Optional) If you run the application as root:

    • All available video modes

    • Current video mode

Known issues on QNX

  • QNX deprecated the use of QCC as CXX compiler. The compilation of a QNX application fails with the error

    QCC is not a full path and was not found in the PATH.
    

    When you compile a QNX application for Kanzi versions before 3.9.4, in build configuration files replace the deprecated QCC compiler command with the q++ command.

    • For CMake, edit Engine/cmake/toolchains/qnx7*.cmake to replace

      set(CMAKE_CXX_COMPILER QCC)
      

      with

      set(CMAKE_CXX_COMPILER q++)
      
    • For SCons, edit:

      • Engine/configs/platforms/qnx/config.py to replace

        default.env["CC"] = os.path.join(toolchain_bin, "QCC")
        default.env["CXX"] = os.path.join(toolchain_bin, "QCC")
        

        with

        default.env["CC"] = os.path.join(toolchain_bin, "q++")
        default.env["CXX"] = os.path.join(toolchain_bin, "q++")
        
      • Engine/scripts/build.py to replace

        re.compile(r'^([^/]*/)*QCC$'),
        

        with

        re.compile(r'^([^/]*/)*q\+\+$'),
        
  • When you use QNX 7.0.0 and update your QNX software through the QNX Software Center, the compilation of Kanzi applications fails with error

    Kanzi-3_6_5-qnx700_screen_aarch64-es3-freetype-static/Engine/include/kanzi/core/cpp/cstdio.hpp:42:12: error: 'std::snprintf' has not been declared
    

    QNX introduced this error in an update of their software development platform where the std::snprintf is missing in header files.

    Workaround: To remove the compilation error, add to the preprocessor flags the -DKZ_USE_C99_SNPRINTF definition.

See also

Deploying Kanzi applications

Application development