Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. [SOLVED] QT and boost : cannot find -llibboost_filesystem...
QtWS25 Last Chance

[SOLVED] QT and boost : cannot find -llibboost_filesystem...

Scheduled Pinned Locked Moved Installation and Deployment
29 Posts 4 Posters 14.7k Views
  • 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.
  • Z Offline
    Z Offline
    zarachbaal
    wrote on 22 Apr 2015, 14:32 last edited by zarachbaal
    #1

    Hi,

    I work with (and I cannot an other version of Qt) :

    • QT Creator 2.4.1 and QT 4.8.4 (with Mingw compiler)
    • boost 1.52

    To build boost :

    • i first added "C:/Qt/qtcreator-2.4.1/mingw/bin" to my PATH variable
    • then opened a command prompt
    • went to "C:/boost_1_52"
    • typed "bootstrap.bat mingw"
    • and then "b2 toolset=gcc build-type=complete stage" (this took a long time (about 2h))

    I would like to use QT creator with the boost library but I come up against difficulties.
    My project is very simple, it's only basic QT code :

    QCoreApplication a(argc, argv) 
    return a.exec()
    

    I just added some includes :

    #include <boost/thread.hpp>
    #include <boost/property_tree/json_parser.hpp> 
    #include <boost/asio.hpp>
    #include <boost/thread.hpp>
    

    In my .pro file I have added :

    INCLUDEPATH += C:/boost_1_52
    LIBS += -L$quote(C:/boost_1_52/stage/lib) \
    -llibboost_filesystem-mgw48-mt-d-1_52 \
    -llibboost_system-mgw48-mt-d-1_52
    

    When I run qmake and then try to build my project it fails with the error

    cannot find -llibboost_filesystem-mgw48-mt-d-1_52
    collect2: ld returned 1 exit status
    

    I tried to replace "-llibboost_filesystem..." with "-lboost_filesystem..." but it does the same.

    I checked and I have got these to files in the C:/boost_1_52/stage/lib
    (actually I have 3 "libboost_filesystem-mgw48-mt-d-1_52" : one .a, one .dll and one .dll.a) (it's the same for "libbost_system-mgw48-mt-d-1_52")

    If I remove the "-llibboost_filesystem..." and "-llibboost_system..." I've got multiple errors like

    "undefined reference to WSAStartup@8"
    "undefined reference to boost::system::generic_category()"
    

    Thank you in advance for your help.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      cybercatalyst
      wrote on 22 Apr 2015, 16:43 last edited by cybercatalyst
      #2

      On a general note, I would always discourage the simultaneous usage of boost and Qt. It makes the code inconsistent, boost in general is more error-prone than the corresponding Qt classes and it is duplicating functionality. Qt is an application development framework, not a GUI library.

      While it is technically possible, it is really awkward in design. Many beginners make that mistake.

      1 Reply Last reply
      0
      • Z Offline
        Z Offline
        zarachbaal
        wrote on 23 Apr 2015, 07:52 last edited by
        #3

        Unfortunately I am working on a project that has been started by someone else and so I have no choice but using Qt and Boost.

        I forgot to say that when I built boost, it said
        "failed updating 32 targets"
        "skipped 64 targets
        "updated 4599 targets"

        I do not know if this is normal or not

        1 Reply Last reply
        0
        • S Offline
          S Offline
          sneubert
          wrote on 23 Apr 2015, 08:56 last edited by
          #4

          Hi zarachbaal,

          for your includes

          #include <boost/thread.hpp>
          #include <boost/property_tree/json_parser.hpp> 
          #include <boost/asio.hpp>
          #include <boost/thread.hpp> 
          

          you dont need boost_filesystem. Asio generates the errors.

          "undefined reference to WSAStartup@8"
          "undefined reference to boost::system::generic_category()"
          

          Asio needs to be link against to additional libraries. Add to your LIBS +=
          1.) Boost_system: -LC:/path/to/boost/libs and -llibboost_system-mgw48-mt-1_52
          2.) On Windows, WS2_32.lib: -LC:/path/to/winsock2/lib and -lWS2_32

          This is tested with boost 1_57 and mingw49 on my win7 system.
          Hope it helps.

          1 Reply Last reply
          0
          • Z Offline
            Z Offline
            zarachbaal
            wrote on 23 Apr 2015, 09:23 last edited by
            #5

            The errors about WSAStartup@8, WSACleanup@0... disappeared, that's a start !

            But I still have a bunch of undefined reference errors.
            A lot have "thread" in their name like :

            undefined reference to `_imp___ZN5boost6threadC1Ev'
            undefined reference to `_imp___ZN5boost6thread4joinEv'
            

            So I guess I also have to add the 'libboost_thread-mgw48-mt-1_52' library ?
            But I only have '.a' files in 'stage/lib' (no '.dll" or '.dll.a' files), and if I do '-llibbost_thread-mgw48-mt-1_52' it says it cannot find the library
            Maybe the lack of '.dll' and '.dll.a' is due to the 'failed updating 32 targets' when I built boost ?

            Also, I still have some
            undefined reference to boost::system::generic_category()
            undefined reference to boost::system::system_category()

            1 Reply Last reply
            0
            • S Offline
              S Offline
              sneubert
              wrote on 23 Apr 2015, 09:44 last edited by
              #6

              I forgot to say, that I had to reorder the header includes to get a build.

              #include <boost/asio.hpp>
              #include <boost/property_tree/json_parser.hpp>
              #include <boost/thread.hpp>
              
              1 Reply Last reply
              0
              • C Offline
                C Offline
                cybercatalyst
                wrote on 23 Apr 2015, 09:46 last edited by
                #7

                I can only suggest you talk with the one introducing boost (if you have to) and see whether you can get rid of it for obvious reasons. You will save yourself a lot of unnecessary work. Before trying that, I wouldn't investigate too much, this is lost time.

                Other than that, I am out here.

                Z 1 Reply Last reply 23 Apr 2015, 11:32
                0
                • S Offline
                  S Offline
                  sneubert
                  wrote on 23 Apr 2015, 09:51 last edited by
                  #8

                  @cybercatalyst
                  I agree, but this wont solve the problem.

                  1 Reply Last reply
                  0
                  • C Offline
                    C Offline
                    cybercatalyst
                    wrote on 23 Apr 2015, 09:54 last edited by
                    #9

                    It does solve the problem, because you the errors you see are linker errors caused by boost. If you just stick to the Qt classes like intended, you will not have those.

                    1 Reply Last reply
                    -1
                    • S Offline
                      S Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 23 Apr 2015, 10:56 last edited by
                      #10

                      @zarachbaal said:

                      undefined reference to `_imp___ZN5boost6threadC1Ev

                      Hi,

                      You're not linking to the boost_thread library.

                      You missing something like:
                      LIBS += -lboost_thread-mgw48-mt-1_52
                      or similar

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

                      Z 1 Reply Last reply 23 Apr 2015, 12:26
                      0
                      • C cybercatalyst
                        23 Apr 2015, 09:46

                        I can only suggest you talk with the one introducing boost (if you have to) and see whether you can get rid of it for obvious reasons. You will save yourself a lot of unnecessary work. Before trying that, I wouldn't investigate too much, this is lost time.

                        Other than that, I am out here.

                        Z Offline
                        Z Offline
                        zarachbaal
                        wrote on 23 Apr 2015, 11:32 last edited by
                        #11

                        @cybercatalyst :

                        In fact I'm using the EyeTribe eye tracking device and the SDK uses the boost library.
                        So I have no choice but using it.

                        1 Reply Last reply
                        0
                        • C Offline
                          C Offline
                          cybercatalyst
                          wrote on 23 Apr 2015, 11:45 last edited by cybercatalyst
                          #12

                          No offense, but in that case you should contact their support instead asking here. I hope you understand, this is not something the community could/should help you with as the source of problems clearly is the usage of boost.

                          (in the sense to make them aware of their fault, you should request them to fix it)

                          S 1 Reply Last reply 23 Apr 2015, 12:22
                          0
                          • C cybercatalyst
                            23 Apr 2015, 11:45

                            No offense, but in that case you should contact their support instead asking here. I hope you understand, this is not something the community could/should help you with as the source of problems clearly is the usage of boost.

                            (in the sense to make them aware of their fault, you should request them to fix it)

                            S Offline
                            S Offline
                            sneubert
                            wrote on 23 Apr 2015, 12:22 last edited by
                            #13

                            @cybercatalyst

                            Using boost and qt together is not uncommon. There are indeed some libraries in boost that have no equivalent replacement in qt. Sure this seems not to be a qt issue, but if you do not want to help, just leave it. I for one, as part of the community saved a lot of time looking at posts like this. And by the way the valuable answers have never been something like "dont do that" or "ask someone else".

                            1 Reply Last reply
                            0
                            • S SGaist
                              23 Apr 2015, 10:56

                              @zarachbaal said:

                              undefined reference to `_imp___ZN5boost6threadC1Ev

                              Hi,

                              You're not linking to the boost_thread library.

                              You missing something like:
                              LIBS += -lboost_thread-mgw48-mt-1_52
                              or similar

                              Z Offline
                              Z Offline
                              zarachbaal
                              wrote on 23 Apr 2015, 12:26 last edited by
                              #14

                              @SGaist :

                              I added "-lboost_thread-mgw48-mt-1_52" at the end of my "LIBS +=..." line.
                              It finds the library but I still have those errors...

                              I also changed the order of my includes as sneubert suggested but that did not help

                              @cybercatalyst :

                              I will contact them about this but I have to make it work on Qt for the next week...

                              1 Reply Last reply
                              0
                              • C Offline
                                C Offline
                                cybercatalyst
                                wrote on 23 Apr 2015, 12:28 last edited by cybercatalyst
                                #15

                                @sneubert said:

                                Using boost and qt together is not uncommon.

                                Yes, you are right! And it's the source for a whole bunch of unnecessary issues. That's why I find it important to state it's the wrong way to go. The fact that boost and qt are being used side-by-side comes from the misconception that people want to somehow get rid of Qt on non-GUI code in lower level stuff because Qt is GUI-only. This is very bad and it's important to remind that Qt is an application framework.

                                This is the only reason I am writing this and if it makes people to rethink then this has been very useful imo.

                                1 Reply Last reply
                                0
                                • S Offline
                                  S Offline
                                  SGaist
                                  Lifetime Qt Champion
                                  wrote on 23 Apr 2015, 12:28 last edited by
                                  #16

                                  Did you check that the library name is correct ? I've based it on the ones you're already using so I might have missed something

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

                                  Z 1 Reply Last reply 23 Apr 2015, 12:41
                                  0
                                  • S SGaist
                                    23 Apr 2015, 12:28

                                    Did you check that the library name is correct ? I've based it on the ones you're already using so I might have missed something

                                    Z Offline
                                    Z Offline
                                    zarachbaal
                                    wrote on 23 Apr 2015, 12:41 last edited by
                                    #17

                                    @SGaist :

                                    Yes I checked and the library is here, i even copy/pasted the name to be sure
                                    Qt does find the library, if I enter a wrong library name it gives an error (error : cannot find "false_library_name")

                                    As I said before I only have "libboost_thread-mgw48-mt-1_52.a" file.
                                    When I had '.a', '.dll' and '.dll.a' files for "libboost_system..."

                                    Maybe it has something to do about it ?

                                    1 Reply Last reply
                                    0
                                    • S Offline
                                      S Offline
                                      SGaist
                                      Lifetime Qt Champion
                                      wrote on 23 Apr 2015, 22:43 last edited by
                                      #18

                                      You can try adding DEFINES += BOOST_THREAD_USE_LIB

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

                                      Z 1 Reply Last reply 24 Apr 2015, 10:02
                                      0
                                      • S SGaist
                                        23 Apr 2015, 22:43

                                        You can try adding DEFINES += BOOST_THREAD_USE_LIB

                                        Z Offline
                                        Z Offline
                                        zarachbaal
                                        wrote on 24 Apr 2015, 10:02 last edited by zarachbaal
                                        #19

                                        @SGaist :

                                        I just added your code, unfortunately it has no effect on the errors.

                                        1 Reply Last reply
                                        0
                                        • S Offline
                                          S Offline
                                          sneubert
                                          wrote on 24 Apr 2015, 11:30 last edited by
                                          #20

                                          I checked my boost lib dir and I do have a libboost_thread-mgw... .dll and .lib so maybe you investigate the build of the boost libraries.

                                          Z 1 Reply Last reply 24 Apr 2015, 14:37
                                          0

                                          10/29

                                          23 Apr 2015, 10:56

                                          topic:navigator.unread, 19
                                          • Login

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