Errors building QGC with docker

Hi everyone,

I’m very new to QGC and docker. I’m on MacOS 10.15 Catalina and I have a fresh Ubuntu 20.04 running on Parallels virtual machine.

It seems easier to compile QGC on Ubuntu 20.04 using docker container, so I chose this route. I’m able to build the container and then build QGC successfully (with sudo) following QGC build documentation.

I tried to run it with ./build/staging/qgroundcontrol-start.sh and I get libSDL2 no such file or directory

./build/staging/QGroundControl: error while loading shared libraries: libSDL2-2.0.so.0: cannot open shared object file: No such file or directory

Any idea?
Thanks

So, I installed sudo aptitude install libsdl2-2.0-0 (aptitude is like apt-get, a bit smarter I find)

Now, I get another error

./build/staging/qgroundcontrol-start.sh 
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, xcb.

Aborted (core dumped)
1 Like

So here is the solution from this post
export QT_DEBUG_PLUGINS=1 to see what’s happening

Then running QGC the terminal gave me many info, and the relevant was

Got keys from plugin meta data ("xcb")
QFactoryLoader::QFactoryLoader() checking directory path "/home/romain/qgroundcontrol/build/staging/platforms" ...
Cannot load library /home/romain/qgroundcontrol/build/staging/Qt/plugins/platforms/libqxcb.so: (libxcb-xinerama.so.0: cannot open shared object file: No such file or directory)
QLibraryPrivate::loadPlugin failed on "/home/romain/qgroundcontrol/build/staging/Qt/plugins/platforms/libqxcb.so" : "Cannot load library /home/romain/qgroundcontrol/build/staging/Qt/plugins/platforms/libqxcb.so: (libxcb-xinerama.so.0: cannot open shared object file: No such file or directory)"

So I installed sudo aptitude install libxcb-xinerama0 and then rerun and it worked!

Adding a new issue to this thread… to keep them together. I am trying to build the latest QGC baseline in a docker container and get the following compile errors.

./usr/lib/x86_64-linux-gnu/libairmap-cpp.so.2.0.0
compiling /project/source/src/QtLocationPlugin/QGeoCodeReplyQGC.cpp
In file included from /project/source/libs/libevents/libevents/libs/cpp/parse/health_and_arming_checks.h:8,
from /project/source/src/Vehicle/HealthAndArmingCheckReport.h:15,
from /project/source/src/Vehicle/Vehicle.h:49,
from /project/source/src/Joystick/Joystick.h:20,
from /project/source/src/Settings/SettingsGroup.h:14,
from /project/source/src/Settings/AppSettings.h:16,
from /project/source/src/QtLocationPlugin/QGCMapUrlEngine.cpp:22:
/project/source/libs/libevents/libevents/libs/cpp/parse/parser.h:13:10: fatal error: nlohmann_json/include/nlohmann/json_fwd.hpp: No such file or directory
13 | #include “nlohmann_json/include/nlohmann/json_fwd.hpp”
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:136365: QGCMapUrlEngine.o] Error 1
make: *** Waiting for unfinished jobs…
In file included from /project/source/libs/libevents/libevents/libs/cpp/parse/health_and_arming_checks.h:8,
from /project/source/src/Vehicle/HealthAndArmingCheckReport.h:15,
from /project/source/src/Vehicle/Vehicle.h:49,
from /project/source/src/Joystick/Joystick.h:20,
from /project/source/src/Settings/SettingsGroup.h:14,
from /project/source/src/Settings/FlightMapSettings.h:12,
from /project/source/src/QGCApplication.h:26,
from /project/source/src/QtLocationPlugin/QGCMapEngine.cpp:18:
/project/source/libs/libevents/libevents/libs/cpp/parse/parser.h:13:10: fatal error: nlohmann_json/include/nlohmann/json_fwd.hpp: No such file or directory
13 | #include “nlohmann_json/include/nlohmann/json_fwd.hpp”
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:135381: QGCMapEngine.o] Error 1

I looked at the docker build script and noticed that the nlohmann-json3-dev was not included. I added it to the apt install part of the build script and rebuilt the image but I still get the same compile error. Not sure how to proceed at this point. Any help would be most appreciated.

Hi @umexsa, did you find a solution to this? I am also having the same issue

Hi @codart, no solution as of yet. I was hoping that either somebody would push a new baseline or offer a suggestion. I tried to add the install the nlohmann library to the container build script, but no joy. I also tried to build from an older baseline, but got other errors during the link phase. I am going to try it again on another machine (native ubuntu) rather than VM and see if that works any better.

Hi @codart, just checking to see if you made any progress. I am able to build the lasted (main) branch of QGC in docker on x86 Linux. I have an x86 machine running Ubuntu 20.04 and the QGC build works great in the Docker container using the following build/run commands:

docker build --file ./deploy/docker/Dockerfile-build-linux -t qgc-linux-docker .
docker run -rm -v ${PWD}:/project/source -v ${PWD}/build:/project/build qgc-linux-docker

The problem I am having is that it won’t build on Mac M1 and I still get the following errors:

./usr/lib/x86_64-linux-gnu/libairmap-cpp.so.2.0.1
compiling /project/source/src/QtLocationPlugin/QGeoCodeReplyQGC.cpp
In file included from /project/source/libs/libevents/libevents/libs/cpp/parse/health_and_arming_checks.h:8,
                 from /project/source/src/Vehicle/HealthAndArmingCheckReport.h:15,
                 from /project/source/src/Vehicle/Vehicle.h:49,
                 from /project/source/src/Joystick/Joystick.h:20,
                 from /project/source/src/Settings/SettingsGroup.h:14,
                 from /project/source/src/Settings/AppSettings.h:16,
                 from /project/source/src/QtLocationPlugin/QGCMapUrlEngine.cpp:22:
/project/source/libs/libevents/libevents/libs/cpp/parse/parser.h:13:10: fatal error: nlohmann_json/include/nlohmann/json_fwd.hpp: No such file or directory
   13 | #include "nlohmann_json/include/nlohmann/json_fwd.hpp"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:136368: QGCMapUrlEngine.o] Error 1
make: *** Waiting for unfinished jobs....
In file included from /project/source/libs/libevents/libevents/libs/cpp/parse/health_and_arming_checks.h:8,
                 from /project/source/src/Vehicle/HealthAndArmingCheckReport.h:15,
                 from /project/source/src/Vehicle/Vehicle.h:49,
                 from /project/source/src/Joystick/Joystick.h:20,
                 from /project/source/src/Settings/SettingsGroup.h:14,
                 from /project/source/src/Settings/FlightMapSettings.h:12,
                 from /project/source/src/QGCApplication.h:26,
                 from /project/source/src/QtLocationPlugin/QGCMapEngine.cpp:18:
/project/source/libs/libevents/libevents/libs/cpp/parse/parser.h:13:10: fatal error: nlohmann_json/include/nlohmann/json_fwd.hpp: No such file or directory
   13 | #include "nlohmann_json/include/nlohmann/json_fwd.hpp"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:135384: QGCMapEngine.o] Error 1

The above error is generated even with using the following recommend build/run commands which add the argument --platform linux/x86_64

||docker build --platform linux/x86_64 --file ./deploy/docker/Dockerfile-build-linux -t qgc-linux-docker .|
|---|---|
|||
docker run --platform linux/x86_64 --rm -v ${PWD}:/project/source -v ${PWD}/build:/project/build qgc-linux-docker

It is clearly a missing library but I can’t seem to figure out what is missing and how to add it to the docker build script. I am thinking it’s possible that the nlohmann_json stuff referenced may not have an ARM version or it’s pulling the wrong version when it sets up the container.

I had the same issue. The solution for me was to make sure that I had added the git submodule to the local repository:

cd libs/libevents/libevents/
git submodule update --init
git submodule update --recursive

then I removed the exisitng docker image, built it again using the commands here (Build using Containers · QGroundControl Developer Guide) , and ran the container again using the commands from the same resource.

I am very new to the concept of submodules, so it may be possible to just recursively add all of them at the very beginning from the root of the source tree. I hope that helps

A-A-Ron