Unsolved Qt and dlib in ubuntu linking problem
-
Hi Guys,
I have installed dlib in my pc with the following command:wget http://dlib.net/files/dlib-19.10.tar.bz2 tar xvf dlib-19.10.tar.bz2 cd dlib-19.10/ mkdir build cd build cmake .. cmake --build . --config Release sudo make install sudo ldconfig cd ..
and then in my Qt project in the Qmake.pro i have link to the library with pkg-config with this line:
PKGCONFIG += dlib-1
but after build the project i got some errors but i am lost...
Here are some of the errors:
/usr/local/include/dlib/test_for_odr_violations.h:24: error: undefined reference to `USER_ERROR__inconsistent_build_configuration__see_dlib_faq_1_' /usr/local/include/dlib/test_for_odr_violations.h:51: error: undefined reference to `DLIB_VERSION_MISMATCH_CHECK__EXPECTED_VERSION_19_10_0'
Hope guys can help me.
Thank you -
Hi,
From the FAQ pointed to by the error message, I understand it as you are mixing debug and release builds. You should build dlib for both and then linked to the correct version based on which mode you build your application with.
-
@SGaist Thank you for your answer.
Indeed in Qtcreator i changed the debug mode to release mode and the errors are gone but if i understand well your answer,
should i reinstall dlib but this time with debug mode? something like thatcd dlib-19.10/ mkdir build cd build cmake .. cmake --build . --config Debug sudo make install sudo ldconfig cd ..
Do the created libraries will be different?
Thanks a lot
-
Yes, a debug build contains all the debug symbols, has usually less optimisations, might assert if certains conditions are not met, might log what happens etc.
-
@SGaist Thank you for your help but after build the Qt project as release to fit my dlib build i got another problem.
If there is no dlib deep learning network defined in my code, i can build but once i add a dlib network, i got a building error/home/jimmy/Desktop/Connected_Robotics_Watson/workco/work/mainWindow.cpp:-1: error: undefined reference to `dlib::cpu::pooling::pooling()'
i am lost... because in a normal cpp code compile with cmake, everything worked well.
Thanks,
-
@Jimmy32 You're not linking dlib.
Try with LIBS/INCLUDEPATH in pro file instead of PKGCONFIG. See http://doc.qt.io/qt-5/qmake-variable-reference.html -
@jsulm Thank you
i have tried this before, i added the lib in the LIBS -ldlib but i got another error:-1: error: /usr/local/lib/libdlib.a(cpu_dlib.cpp.o): undefined reference to symbol 'cblas_sscal'
...
-
@Jimmy32 Can you show your pro file?
Does the dlib depend on other libraries (you can check with ldd)? -
@jsulm my .pro file:
QT += network QT += widgets TEMPLATE = app TARGET = Connected INCLUDEPATH += /usr/local/include LIBS += -L /usr/local/lib -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -ldlib QMAKE_CXXFLAGS += -std=c++11 # PKGCONFIG = dlib-1 # Input HEADERS += mainWindow.hpp SOURCES += main.cpp mainWindow.cpp
and for ldd i dont have the executable as it cant build...
-
@Jimmy32 Remove space between -L and /usr/local/lib
You don't need the executable. What I meant is:ldd /usr/local/lib/dlib.so
-
@jsulm my library is static and i typed
ldd /usr/local/lib/libdlib.a
but it gave me " not a dynamic executable "
-
@Jimmy32 Did you remove the space? Don't forget to run qmake afterwards.
-
@jsulm yes i did remove but still the same
-
@Jimmy32 My guess is that dlib depends on some other libs you're currently not linking
-
@jsulm after some search, dlib depends on pthread and x11
-
dlib installation and Qt - dlib linking
https://www.youtube.com/watch?v=YkTHq65FPa4