I'm trying to port some old stuff to the recently released QNX SDP8 on Raspberry Pi 4. For that I need to build the SDL2 for aarch64le as a library. I don't need Audio and only need EGL / OpenGLES2+ working for now.
Below is what I tried so far and how it fails, but please don't focus on helping to solve the exact fail messages. I think my problem is I don't know how to configure SDL build in the first place. I don't want to "solve" the build issues by forcing it to link with the right libs and later deal with glorious fails in runtime because it was built with the wrong options in the first place.
So, anyone has built any of these repos - please post here which repo, which options, etc.
Tried 3 different approaches:
**Approach A: QNX Ports repository using CMAKE: **
mkdir build_qnx_rpi4
cd build_qnx_rpi4
source ~/qnx800/qnxsdp_env.sh
cmake .. \
-DCMAKE_SYSTEM_NAME=QNX \
-DCMAKE_SYSROOT=$QNX_TARGET/aarch64le/usr \
-DCMAKE_C_COMPILER=$QNX_HOST/usr/bin/qcc \
-DCMAKE_CXX_COMPILER=$QNX_HOST/usr/bin/qcc \
-DCMAKE_C_FLAGS="-Vgcc_ntoaarch64le" \
-DCMAKE_BUILD_TYPE=Release \
-DSDL_AUDIO_DRIVER_JACK=OFF \
-DSDL_AUDIO_DRIVER_PIPEWIRE=OFF \
-DSDL_AUDIO_DRIVER_PULSEAUDIO=OFF \
-DSDL_AUDIO_DRIVER_SNDIO=OFF \
-DSDL_AUDIO_DRIVER_ALSA=OFF \
-DSDL_AUDIO=OFF \
-DVIDEO_WAYLAND=OFF
cmake --build . --verbose -- -j4
Fails for:
[100%] Linking C static library libSDL2.a
aarch64-unknown-nto-qnx8.0.0-ld: cannot find -lpthread: No such file or directory
**Approach B: QNX Ports repository using CONFIG script: **
./configure \
--host=aarch64-unknown-nto-qnx8.0.0 \
--prefix=$QNX_TARGET/usr \
CFLAGS="-Vgcc_ntoaarch64le" \
CXXFLAGS="-Vgcc_ntoaarch64le" \
LTCFLAGS="-Vgcc_ntoaarch64le --sysroot=$QNX_TARGET -I$QNX_TARGET" \
CC=qcc \
CXX=qcc \
--disable-shared \
--disable-pulseaudio \
--disable-alsa \
--disable-sndio \
--disable-pipewire \
--disable-jack \
--disable-video-wayland \
--disable-audio
Compiles, then fails for:
CC build/SDL.lo
cc: Can't specify -P, -C, -E, -c or -S with -o and have multiple files
make: *** [Makefile:272: build/SDL.lo] Error 1
make -d shows the reason is SDL.lo is present twice:
echo " CC " build/SDL.lo;/bin/bash ./libtool --quiet --tag=CC --mode=compile qcc -Vgcc_ntoaarch64le -DUSING_GENERATED_CONFIG_H -Iinclude -I/home/deb/qnx_workspace/libs/src/SDL/include -DSDL_BUILD_MAJOR_VERSION=2 -DSDL_BUILD_MINOR_VERSION=30 -DSDL_BUILD_MICRO_VERSION=11 -Wall -Wno-unused-local-typedefs -fno-strict-aliasing -fvisibility=hidden -Wdeclaration-after-statement -Werror=declaration-after-statement -DMESA_EGL_NO_X11_HEADERS -DEGL_NO_X11 -D_REENTRANT -MMD -MT build/SDL.lo -c /home/deb/qnx_workspace/libs/src/SDL/src/SDL.c -o build/SDL.lo
Putting child 0x31bab870 (build/SDL.lo) PID 14592 on the chain.
Live child 0x31bab870 (build/SDL.lo) PID 14592
CC build/SDL.lo
cc: Can't specify -P, -C, -E, -c or -S with -o and have multiple files
Oddly enough, if I manually run the libtool just deleting the 1st SDL.lo it will work. However I don't need a .lo, I need a .a and .so :)
**Approach C: SDL main repository **
Buiding for QNX is supposedly fixed in SDL2, which exactly is the one I need. However I couldn't checkout a SDL2 release that actually builds. I can built multiple releases of SDL2 for Raspbian, also can build at leaast one SDL3 for QNX, but SDL2 for QNX ... won't even compile for me.
For approach B, the problem is that while qcc/q++ use a lot of gcc's toolchain under the covers, it isn't a drop in replacement. They don't support the same command line arguments as gcc/g++. This can cause problems like this.
If I ask the build to spit out the command line to qcc I see
$ make V=1
/bin/bash ./build-scripts//updaterev.sh --vendor ""
/bin/bash ./libtool --tag=CC --mode=compile qcc -Vgcc_ntoaarch64le -DUSING_GENERATED_CONFIG_H -Iinclude -I/home/dphipps/temp/SDL/include -DSDL_BUILD_MAJOR_VERSION=2 -DSDL_BUILD_MINOR_VERSION=30 -DSDL_BUILD_MICRO_VERSION=11 -Wall -Wno-unused-local-typedefs -fno-strict-aliasing -fvisibility=hidden -Wdeclaration-after-statement -Werror=declaration-after-statement -DMESA_EGL_NO_X11_HEADERS -DEGL_NO_X11 -D_REENTRANT -MMD -MT build/SDL.lo -c /home/dphipps/temp/SDL/src/SDL.c -o build/SDL.lo
libtool: compile: qcc -Vgcc_ntoaarch64le -DUSING_GENERATED_CONFIG_H -Iinclude -I/home/dphipps/temp/SDL/include -DSDL_BUILD_MAJOR_VERSION=2 -DSDL_BUILD_MINOR_VERSION=30 -DSDL_BUILD_MICRO_VERSION=11 -Wall -Wno-unused-local-typedefs -fno-strict-aliasing -fvisibility=hidden -Wdeclaration-after-statement -Werror=declaration-after-statement -DMESA_EGL_NO_X11_HEADERS -DEGL_NO_X11 -D_REENTRANT -MMD -MT build/SDL.lo -c /home/dphipps/temp/SDL/src/SDL.c -o build/SDL.o
cc: Can't specify -P, -C, -E, -c or -S with -o and have multiple files
make: *** [Makefile:272: build/SDL.lo] Error 1
In this case the problem is the-MMD -MT build/SDL.lo
bit. I think qcc is just eating the -MMD and -MT arguments as it doesn't recognize them. That just leaves the build/SDL.lo
bit which it thinks is an input file, hence the error.
Easiest way to get around this is to just to disable dependency tracking by adding --disable-dependency-tracking
to your configure's command line. Be careful if you are making code changes as I expect this will mess up the build processes' ability to detect when a header file change should cause a rebuild.
If you want to play around with configure to 'fix' the problem try modifying the configure script to change the line
DEPENDENCY_TRACKING_OPTIONS="-MMD -MT \$@"
to
DEPENDENCY_TRACKING_OPTIONS="-Xcompiler '-Wc\,-MMD\,\$(@:.lo=.d)\,-MT\,\$@'"
The escaping of the commas is to prevent a failure during configure where it uses sed to do some string manipulation. I think it is using commas as separators.
For approach A what you are doing should work fine. I don't know what in CMake is trying to directly add -lpthread to the linker as I wasn't able to reproduce your problem.
One possibility is that your version of cmake isn't defining the QNX variable automatically. This causes SDL's sdlchecks.cmake to come to the wrong conclusion about what is required for pthread support. You can try explicitly defining it by adding -DQNX=1
to the command line of cmake's configure step.
That said I had to add -DSDL_X11=off
to my CMake configuration as it was finding my host's local X11 headers which was causing all sorts of (different) problems. Perhaps something similar is going on here? CMake is finding pkg information from your host system instead of the QNX toolchain/sysroot and that is mucking things up for you.
You can get CMake to stop finding things from your local packages by setting the PKG_CONFIG_LIBDIR and PKG_CONFIG_PATH environment variables to dummy values before creating your build environment. Eg:
PKG_CONFIG_LIBDIR=/nope \
PKG_CONFIG_PATH=/sorry \
cmake .. \
-DCMAKE_SYSTEM_NAME=QNX \
-DCMAKE_SYSROOT=$QNX_TARGET/aarch64le/usr \
-DCMAKE_C_COMPILER=$QNX_HOST/usr/bin/qcc \
-DCMAKE_CXX_COMPILER=$QNX_HOST/usr/bin/qcc \
-DCMAKE_C_FLAGS="-Vgcc_ntoaarch64le" \
-DCMAKE_BUILD_TYPE=Release \
-DSDL_AUDIO_DRIVER_JACK=OFF \
-DSDL_AUDIO_DRIVER_PIPEWIRE=OFF \
-DSDL_AUDIO_DRIVER_PULSEAUDIO=OFF \
-DSDL_AUDIO_DRIVER_SNDIO=OFF \
-DSDL_AUDIO_DRIVER_ALSA=OFF \
-DSDL_AUDIO=OFF \
-DVIDEO_WAYLAND=OFF
Edit1 2025-04-08: