Skip to content

Required changes to support QNX8 for aarch64le - #1602

Open
eresgit wants to merge 9 commits into
eclipse-paho:developfrom
eresgit:develop
Open

Required changes to support QNX8 for aarch64le#1602
eresgit wants to merge 9 commits into
eclipse-paho:developfrom
eresgit:develop

Conversation

@eresgit

@eresgit eresgit commented May 17, 2025

Copy link
Copy Markdown

Make sure to call the QNX environment scripts in your system before building

…functions.

Signed-off-by: Erlend Ese <erlendese@gmail.com>
@eresgit eresgit mentioned this pull request May 17, 2025
@jclsn

jclsn commented May 13, 2026

Copy link
Copy Markdown

@eresgit Just tried this and it doesn't build for me. What are the required build commands?

@jclsn jclsn left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two small nits

Comment thread src/MQTTPacket.h Outdated
Comment thread src/MQTTPacket.h Outdated
@jclsn

jclsn commented May 13, 2026

Copy link
Copy Markdown

I could get it to build using only these changes

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index a4854c2..4e52956 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -80,6 +80,7 @@ elseif(UNIX)
     set(LIBS_SYSTEM compat pthread)
   elseif(CMAKE_SYSTEM_NAME MATCHES "QNX")
     set(LIBS_SYSTEM c socket)
+    add_definitions(-D_QNX_SOURCE)
   else()
     set(LIBS_SYSTEM c pthread)
   endif()
diff --git a/src/SHA1.c b/src/SHA1.c
index 5c4c349..c0928dd 100644
--- a/src/SHA1.c
+++ b/src/SHA1.c
@@ -16,6 +16,12 @@
 
 #include "SHA1.h"
 
+#if defined(__QNXNTO__)
+#include <gulliver.h>
+#define be32toh(x) ENDIAN_BE32(x)
+#define htobe32(x) ENDIAN_BE32(x)
+#endif
+
 #if !defined(OPENSSL)
 #if defined(_WIN32)
 #pragma comment(lib, "crypt32.lib")
diff --git a/src/Socket.h b/src/Socket.h
index 396b2a6..f1d7128 100644
--- a/src/Socket.h
+++ b/src/Socket.h
@@ -62,8 +62,10 @@
 #include <arpa/inet.h>
 #include <netdb.h>
 #ifdef __QNXNTO__
+#ifndef AI_ADDRCONFIG
 #define AI_ADDRCONFIG 0
 #endif
+#endif
 #include <stdio.h>
 #include <unistd.h>
 #include <errno.h>
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 32ccbf8..c08f431 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -15,6 +15,10 @@ elseif(UNIX)
 		set(LIBS_SYSTEM c dl pthread)
 	elseif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
 		set(LIBS_SYSTEM compat pthread)
+
+	elseif(CMAKE_SYSTEM_NAME MATCHES "QNX")
+		set(LIBS_SYSTEM c socket)
+		add_definitions(-D_QNX_SOURCE)
 	else()
 		set(LIBS_SYSTEM c pthread)
 	endif()

@eresgit

eresgit commented May 13, 2026

Copy link
Copy Markdown
Author

@eresgit Just tried this and it doesn't build for me. What are the required build commands?

@jclsn I used cmake to cross compile in windows for aarch64le by setting up a qnx-toolchain.cmake file:

set(CMAKE_C_FLAGS "-Vgcc_ntoaarch64le -Wall -fmessage-length=0 -D_QNX_SOURCE -DGULLIVER")
set(CMAKE_EXE_LINKER_FLAGS "-Vgcc_ntoaarch64le -L${QNX_TARGET}/aarch64le/lib -L${QNX_TARGET}/aarch64le/usr/lib")
set(CMAKE_C_STANDARD_LIBRARIES "-lsocket -lc")
add_definitions(-DQNX_OS -D_QNX_SOURCE -DGULLIVER)

I used a batch script that sets up environment variables and then calls qnxsdp-env.bat provided by QNX, and then a cmake batch script:

@echo off
echo Running CMake with QNX toolchain...
cmake -S .. -B . ^
    -G "Unix Makefiles" ^
    -DCMAKE_TOOLCHAIN_FILE="%~dp0qnx-toolchain.cmake" ^
    -DCMAKE_MAKE_PROGRAM="%QNX_HOST%/usr/bin/make.exe" ^
    -DPAHO_BUILD_SHARED=ON ^
    -DPAHO_BUILD_STATIC=ON ^
    -DPAHO_WITH_SSL=OFF ^
    -DPAHO_HIGH_PERFORMANCE=ON ^
    -DPAHO_BUILD_DOCUMENTATION=OFF ^
    -DPAHO_BUILD_SAMPLES=ON ^
    -DCMAKE_EXE_LINKER_FLAGS="-lsocket"

if errorlevel 1 (
    echo CMake configuration failed!
    exit /b 1
)

echo Building...
"%QNX_HOST%/usr/bin/make.exe" VERBOSE=1

Hope that helps!

@eresgit

eresgit commented May 13, 2026

Copy link
Copy Markdown
Author

I could get it to build using only these changes

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index a4854c2..4e52956 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -80,6 +80,7 @@ elseif(UNIX)
     set(LIBS_SYSTEM compat pthread)
   elseif(CMAKE_SYSTEM_NAME MATCHES "QNX")
     set(LIBS_SYSTEM c socket)
+    add_definitions(-D_QNX_SOURCE)
   else()
     set(LIBS_SYSTEM c pthread)
   endif()

Looks like your CMakeLists.txt is not updated, it's missing -DGULLIVER

@jclsn

jclsn commented May 14, 2026

Copy link
Copy Markdown

I could get it to build using only these changes

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index a4854c2..4e52956 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -80,6 +80,7 @@ elseif(UNIX)
     set(LIBS_SYSTEM compat pthread)
   elseif(CMAKE_SYSTEM_NAME MATCHES "QNX")
     set(LIBS_SYSTEM c socket)
+    add_definitions(-D_QNX_SOURCE)
   else()
     set(LIBS_SYSTEM c pthread)
   endif()

Looks like your CMakeLists.txt is not updated, it's missing -DGULLIVER

Yeah, but it built for me anyway. Not sure why the GULLIVER is needed. With my patch after sourcing the QNX setup script, I could build with

cmake -DCMAKE_SYSTEM_NAME=QNX -B build -S .
cmake --build build

I do have a custom setup script though that directly builds with gcc instead of using qcc, because qcc isn't able to generate a compile_commands.json file.

@jclsn

jclsn commented May 14, 2026

Copy link
Copy Markdown

@eresgit Just tried this and it doesn't build for me. What are the required build commands?

@jclsn I used cmake to cross compile in windows for aarch64le by setting up a qnx-toolchain.cmake file:

set(CMAKE_C_FLAGS "-Vgcc_ntoaarch64le -Wall -fmessage-length=0 -D_QNX_SOURCE -DGULLIVER")
set(CMAKE_EXE_LINKER_FLAGS "-Vgcc_ntoaarch64le -L${QNX_TARGET}/aarch64le/lib -L${QNX_TARGET}/aarch64le/usr/lib")
set(CMAKE_C_STANDARD_LIBRARIES "-lsocket -lc")
add_definitions(-DQNX_OS -D_QNX_SOURCE -DGULLIVER)

I used a batch script that sets up environment variables and then calls qnxsdp-env.bat provided by QNX, and then a cmake batch script:

@echo off
echo Running CMake with QNX toolchain...
cmake -S .. -B . ^
    -G "Unix Makefiles" ^
    -DCMAKE_TOOLCHAIN_FILE="%~dp0qnx-toolchain.cmake" ^
    -DCMAKE_MAKE_PROGRAM="%QNX_HOST%/usr/bin/make.exe" ^
    -DPAHO_BUILD_SHARED=ON ^
    -DPAHO_BUILD_STATIC=ON ^
    -DPAHO_WITH_SSL=OFF ^
    -DPAHO_HIGH_PERFORMANCE=ON ^
    -DPAHO_BUILD_DOCUMENTATION=OFF ^
    -DPAHO_BUILD_SAMPLES=ON ^
    -DCMAKE_EXE_LINKER_FLAGS="-lsocket"

if errorlevel 1 (
    echo CMake configuration failed!
    exit /b 1
)

echo Building...
"%QNX_HOST%/usr/bin/make.exe" VERBOSE=1

Hope that helps!

We should make sure that the patch builds with the standard Makefile or CMake approach instead of relying on custom toolchains.

@jclsn

jclsn commented May 14, 2026

Copy link
Copy Markdown

@eresgit I added another PR that fixes the build also for Makefiles and not only CMake

-DGULLIVER should not be needed, as it is handled by gulliver.h

#1672

@eresgit

eresgit commented May 14, 2026

Copy link
Copy Markdown
Author

@eresgit Just tried this and it doesn't build for me. What are the required build commands?

@jclsn I used cmake to cross compile in windows for aarch64le by setting up a qnx-toolchain.cmake file:

set(CMAKE_C_FLAGS "-Vgcc_ntoaarch64le -Wall -fmessage-length=0 -D_QNX_SOURCE -DGULLIVER")
set(CMAKE_EXE_LINKER_FLAGS "-Vgcc_ntoaarch64le -L${QNX_TARGET}/aarch64le/lib -L${QNX_TARGET}/aarch64le/usr/lib")
set(CMAKE_C_STANDARD_LIBRARIES "-lsocket -lc")
add_definitions(-DQNX_OS -D_QNX_SOURCE -DGULLIVER)

I used a batch script that sets up environment variables and then calls qnxsdp-env.bat provided by QNX, and then a cmake batch script:

@echo off
echo Running CMake with QNX toolchain...
cmake -S .. -B . ^
    -G "Unix Makefiles" ^
    -DCMAKE_TOOLCHAIN_FILE="%~dp0qnx-toolchain.cmake" ^
    -DCMAKE_MAKE_PROGRAM="%QNX_HOST%/usr/bin/make.exe" ^
    -DPAHO_BUILD_SHARED=ON ^
    -DPAHO_BUILD_STATIC=ON ^
    -DPAHO_WITH_SSL=OFF ^
    -DPAHO_HIGH_PERFORMANCE=ON ^
    -DPAHO_BUILD_DOCUMENTATION=OFF ^
    -DPAHO_BUILD_SAMPLES=ON ^
    -DCMAKE_EXE_LINKER_FLAGS="-lsocket"

if errorlevel 1 (
    echo CMake configuration failed!
    exit /b 1
)

echo Building...
"%QNX_HOST%/usr/bin/make.exe" VERBOSE=1

Hope that helps!

We should make sure that the patch builds with the standard Makefile or CMake approach instead of relying on custom toolchains.

The toolchain is from QNX and hardly custom:
https://www.qnx.com/developers/docs/qnxeverywhere/com.qnx.doc.qpg/topic/port_CMake.html

@eresgit
eresgit requested a review from jclsn May 14, 2026 09:54
@eresgit eresgit changed the title Add support for QNX8 Required changes to support QNX8 for aarch64le May 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants