0

I'm trying to build my Qt app using libcamera on Raspberry Pi, but the qt project won't build, instead showing error: DSO missing from command line. I have build libcamera from source (it's a .so lib), and included it in my .pro file:

INCLUDEPATH += $$PWD/../libcamera/include
LIBS += -L$$PWD/../libcamera/build/src/libcamera -lcamera

I also tried this, with the same result:

INCLUDEPATH += /usr/local/include/libcamera
LIBS += -lcamera

And the exact error:

error: /usr/local/lib/aarch64-linux-gnu/libcamera-base.so.0.0.4: error adding symbols: DSO missing from command line

I'm pretty sure I'm including it wrong, but I have no idea how to include it the way for it to finally work. How do I include this correctly?

Edit: LibCamera is installed correctly, as this example from here runs normally. Also other Qt apps run, this one does not.

As for includes - $PWD is actually /home/pi/app and in /home/pi/libcamera I have built libcamera from source.

But /usr/local/include/libcamera does contain header files, and /usr/local/lib/aarch64-linux-gnu does contain libcamera-base.so.

Build command with full output:

g++ -Wl,-rpath,/opt/Qt/6.2.4-armv8/lib -Wl,-rpath-link,/opt/Qt/6.2.4-armv8/lib
 -o app LibCamera.o main.o mainwindow.o qrc_resource.o moc_mainwindow.o   `pkg-config --cflags --libs opencv4` -lpigpiod_if2
 -lrt -ldl -lpython3.9 -lcamera /opt/Qt/6.2.4-armv8/lib/libQt6Charts.so -pthread
 /opt/Qt/6.2.4-armv8/lib/libQt6OpenGLWidgets.so /opt/Qt/6.2.4-armv8/lib/libQt6Widgets.so /opt/Qt/6.2.4-armv8/lib/libQt6OpenGL.so 
/opt/Qt/6.2.4-armv8/lib/libQt6Gui.so -lEGL /opt/Qt/6.2.4-armv8/lib/libQt6Core.so -lpthread -lGLESv2   

/usr/bin/ld: LibCamera.o: undefined reference to symbol '_ZN9libcamera8UniqueFD5resetEi'
/usr/bin/ld: /usr/local/lib/aarch64-linux-gnu/libcamera-base.so.0.0.4: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [Makefile:285: app] Error 1

And part of my .pro file (skipping sources, headers and resources):

QT       += core gui charts
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++14
QT_CONFIG -= no-pkg-config
INCLUDEPATH += /usr/include/opencv4
LIBS += `pkg-config --cflags --libs opencv4`
LIBS+= -lpigpiod_if2 -lrt -ldl
CONFIG += no_keywords
INCLUDEPATH += /usr/include/python3.9
LIBS += -lpython3.9
INCLUDEPATH += /usr/local/include/libcamera/libcamera
LIBS += -lcamera

pkg-config libcamera --cflags shows -I/usr/local/include/libcamera and pkg-config libcamera --libs shows -L/usr/local/lib/aarch64-linux-gnu -lcamera -lcamera-base

  • Please [edit] your question and add more details. Your `INCLUDEPATH` values seem inconsistent. Did you install `libcamera` into `/usr/local`? Didyou check that the header and library files can be found in the specified directories? What directory is `$PWD`? Show your directory structure, the full `.pro` file and the build command with full output. I would expect error messages mentioning the missing symbol(s). You probably did not specify all required libraries, see https://stackoverflow.com/q/19901934/10622916 – Bodo Apr 14 '23 at 10:14
  • @Bodo I edited, including (hopefully) everything you mentioned. – robotanical Apr 17 '23 at 06:18
  • 1
    Does it work if you add `-lcamera-base` to `LIBS`? If not: Can you check which library provides the symbol `_ZN9libcamera8UniqueFD5resetEi`? `libcamera-base`? – Bodo Apr 17 '23 at 09:05
  • Yup, adding -lcamera-base fixed this! Thanks, add it as an answer so I can accept. – robotanical Apr 17 '23 at 11:19
  • The correct way to get the compiler and linker arguments might be `pkg-config`. Please show the output of `pkg-config libcamera --cflags` and `pkg-config libcamera --libs`. See https://stackoverflow.com/q/3517694/10622916 – Bodo Apr 17 '23 at 11:42
  • `pkg-config libcamera --cflags` shows `-I/usr/local/include/libcamera` and `pkg-config libcamera --libs` shows `-L/usr/local/lib/aarch64-linux-gnu -lcamera -lcamera-base`. – robotanical Apr 17 '23 at 11:49
  • Please add all requested information to the question. – Bodo Apr 17 '23 at 11:58

1 Answers1

0

The correct way to get the compiler and linker arguments seems to be pkg-config.

Referring to the answers to Linking libraries to a QT project using pkg-config output you should use

QT_CONFIG -= no-pkg-config
CONFIG += link_pkgconfig
PKGCONFIG += libcamera

and remove the manual specification of INCLUDEPATH and LIBS.

According to different answers, the first line QT_CONFIG ... may or may not be necessary.

I did not test the proposed solution.

Bodo
  • 9,287
  • 1
  • 13
  • 29