Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt and dlib in ubuntu linking problem
Forum Updated to NodeBB v4.3 + New Features

Qt and dlib in ubuntu linking problem

Scheduled Pinned Locked Moved Unsolved General and Desktop
16 Posts 4 Posters 6.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jimmy32
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      J 1 Reply Last reply
      1
      • SGaistS SGaist

        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.

        J Offline
        J Offline
        Jimmy32
        wrote on last edited by
        #3

        @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 that

        cd 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

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          J 1 Reply Last reply
          1
          • SGaistS SGaist

            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.

            J Offline
            J Offline
            Jimmy32
            wrote on last edited by
            #5

            @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,

            jsulmJ 1 Reply Last reply
            0
            • J Jimmy32

              @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,

              jsulmJ Online
              jsulmJ Online
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @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

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              J 1 Reply Last reply
              0
              • jsulmJ jsulm

                @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

                J Offline
                J Offline
                Jimmy32
                wrote on last edited by
                #7

                @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'
                

                ...

                jsulmJ 1 Reply Last reply
                0
                • J Jimmy32

                  @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'
                  

                  ...

                  jsulmJ Online
                  jsulmJ Online
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @Jimmy32 Can you show your pro file?
                  Does the dlib depend on other libraries (you can check with ldd)?

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  J 1 Reply Last reply
                  0
                  • jsulmJ jsulm

                    @Jimmy32 Can you show your pro file?
                    Does the dlib depend on other libraries (you can check with ldd)?

                    J Offline
                    J Offline
                    Jimmy32
                    wrote on last edited by
                    #9

                    @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...

                    jsulmJ 1 Reply Last reply
                    0
                    • J Jimmy32

                      @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...

                      jsulmJ Online
                      jsulmJ Online
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @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
                      

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      J 1 Reply Last reply
                      0
                      • jsulmJ jsulm

                        @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
                        
                        J Offline
                        J Offline
                        Jimmy32
                        wrote on last edited by
                        #11

                        @jsulm my library is static and i typed

                        ldd /usr/local/lib/libdlib.a 
                        

                        but it gave me " not a dynamic executable "

                        jsulmJ 1 Reply Last reply
                        0
                        • J Jimmy32

                          @jsulm my library is static and i typed

                          ldd /usr/local/lib/libdlib.a 
                          

                          but it gave me " not a dynamic executable "

                          jsulmJ Online
                          jsulmJ Online
                          jsulm
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          @Jimmy32 Did you remove the space? Don't forget to run qmake afterwards.

                          https://forum.qt.io/topic/113070/qt-code-of-conduct

                          J 1 Reply Last reply
                          0
                          • jsulmJ jsulm

                            @Jimmy32 Did you remove the space? Don't forget to run qmake afterwards.

                            J Offline
                            J Offline
                            Jimmy32
                            wrote on last edited by
                            #13

                            @jsulm yes i did remove but still the same

                            jsulmJ 1 Reply Last reply
                            0
                            • J Jimmy32

                              @jsulm yes i did remove but still the same

                              jsulmJ Online
                              jsulmJ Online
                              jsulm
                              Lifetime Qt Champion
                              wrote on last edited by
                              #14

                              @Jimmy32 My guess is that dlib depends on some other libs you're currently not linking

                              https://forum.qt.io/topic/113070/qt-code-of-conduct

                              J 1 Reply Last reply
                              0
                              • jsulmJ jsulm

                                @Jimmy32 My guess is that dlib depends on some other libs you're currently not linking

                                J Offline
                                J Offline
                                Jimmy32
                                wrote on last edited by
                                #15

                                @jsulm after some search, dlib depends on pthread and x11

                                1 Reply Last reply
                                0
                                • E Offline
                                  E Offline
                                  Eyyup
                                  wrote on last edited by Eyyup
                                  #16

                                  dlib installation and Qt - dlib linking
                                  https://www.youtube.com/watch?v=YkTHq65FPa4

                                  1 Reply Last reply
                                  1

                                  • Login

                                  • Login or register to search.
                                  • First post
                                    Last post
                                  0
                                  • Categories
                                  • Recent
                                  • Tags
                                  • Popular
                                  • Users
                                  • Groups
                                  • Search
                                  • Get Qt Extensions
                                  • Unsolved