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. Linking Boost libs required by ASIO on Windows giving undefined reference errors

Linking Boost libs required by ASIO on Windows giving undefined reference errors

Scheduled Pinned Locked Moved Installation and Deployment
25 Posts 7 Posters 23.6k 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.
  • G Offline
    G Offline
    golgobot
    wrote on last edited by
    #2

    Ping? This is really a deal breaker for Qt. I really need a way to link those libraries correctly. I've poured through the qmake documentation and can't find anything new that might help me. I don't usually post to forums unless I get really desperate. So help! :)

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mlong
      wrote on last edited by
      #3

      While we all appreciate the urgency you feel for your problem, please don't badger everyone for help. Especially after less than an hour and a half. Doing so is very rude and, if anything, will hinder your chances of getting effective and timely help.

      If anyone has useful input regarding your problem, they will post. Be patient.

      Software Engineer
      My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

      1 Reply Last reply
      0
      • G Offline
        G Offline
        golgobot
        wrote on last edited by
        #4

        Noted. I'll be patient.

        1 Reply Last reply
        0
        • F Offline
          F Offline
          florent.revelut
          wrote on last edited by
          #5

          Your compilation log does not fit with your example: in your log, your linker tries to link
          @main.o mainwindow.o voiceview.o serialsid.o moc_mainwindow.o moc_voiceview.o@
          In your .pro file, you have only one file, without preprocessing (moc)

          After a bit of googling, (stackoverflow), seems to be a common problem, even without using Qt... Did you manage to link something without Qt already with boost ? From what I've read, you're doing it right.

          1 Reply Last reply
          0
          • G Offline
            G Offline
            golgobot
            wrote on last edited by
            #6

            You are correct. Excuse the misleading compile output. I was trying to say that the important part of the output was the reference errors. Here is a more appropriate output generated from the exact example above.

            bq.
            Running build steps for project SIDController...
            Configuration unchanged, skipping qmake step.
            Starting: "C:\Qt\2010.05\mingw\bin\mingw32-make.exe"
            C:/Qt/2010.05/mingw/bin/mingw32-make -f Makefile.Debug
            mingw32-make[1]: Entering directory C:/workspaces/qt/SIDController-build-desktop' g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-subsystem,console -mthreads -Wl -o debug\SIDController.exe debug/main.o -L"c:\Qt\2010.05\qt\lib" -LC:/workspaces/qt/SIDController/../../../libs/boost_1_44/stage/lib/ -llibboost_filesystem-vc100-mt-sgd-1_44 -llibboost_system-vc100-mt-sgd-1_44 -lQtGuid4 -lQtCored4 mingw32-make[1]: Leaving directory C:/workspaces/qt/SIDController-build-desktop'
            debug/main.o: In function _static_initialization_and_destruction_0': C:\workspaces\qt\SIDController-build-desktop/../../../libs/boost_1_44/boost/system/error_code.hpp:214: undefined reference to boost::system::generic_category()'
            C:\workspaces\qt\SIDController-build-desktop/../../../libs/boost_1_44/boost/system/error_code.hpp:215: undefined reference to boost::system::generic_category()' C:\workspaces\qt\SIDController-build-desktop/../../../libs/boost_1_44/boost/system/error_code.hpp:216: undefined reference to boost::system::system_category()'
            debug/main.o:C:\workspaces\qt\SIDController-build-desktop/../../../libs/boost_1_44/boost/system/error_code.hpp:211: undefined reference to boost::system::system_category()' debug/main.o:C:\workspaces\qt\SIDController-build-desktop/../../../libs/boost_1_44/boost/asio/detail/impl/winsock_init.ipp:39: undefined reference to WSAStartup@8'
            debug/main.o:C:\workspaces\qt\SIDController-build-desktop/../../../libs/boost_1_44/boost/asio/detail/impl/winsock_init.ipp:48: undefined reference to `WSACleanup@0'
            collect2: ld returned 1 exit status
            mingw32-make[1]: *** [debug\SIDController.exe] Error 1
            mingw32-make: *** [debug] Error 2
            The process "C:\Qt\2010.05\mingw\bin\mingw32-make.exe" exited with code 2.
            Error while building project SIDController (target: Desktop)
            When executing build step 'Make'

            The problem remains. I am unable to successfully link boost_system and boost_filesystem. Thanks for pointing that out.

            1 Reply Last reply
            0
            • F Offline
              F Offline
              florent.revelut
              wrote on last edited by
              #7

              Another string which looks damn strange : you're compiling Qt with mingwin whereas you compiled boost with visual 10 (vc100 in library name).
              Msvc and mingwin have different ABIs and can't be linekd together.
              Either compile your Qt with Visual 2010 (you'll have to do it yourself) or compile boost with mingwin

              1 Reply Last reply
              0
              • L Offline
                L Offline
                leon.anavi
                wrote on last edited by
                #8

                Hi golgobot,

                In my opinion "this article":http://www.richelbilderbeek.nl/CppLinkErrorUndefinedReferenceToBoostSystemGet_system_categoryQtCreator.htm might be useful in your case. The suggested solution is to add the following line to your .pro file:

                @LIBS += -lboost_system@

                Cheers,
                Leon

                http://anavi.org/

                1 Reply Last reply
                0
                • F Offline
                  F Offline
                  florent.revelut
                  wrote on last edited by
                  #9

                  Leon:
                  He's already got it (last -l, slightly differently formatted to take into account library):
                  @win32: LIBS += -L$$PWD/../../../libs/boost_1_44/stage/lib/ -llibboost_filesystem-vc100-mt -llibboost_system-vc100-mt@

                  1 Reply Last reply
                  0
                  • L Offline
                    L Offline
                    leon.anavi
                    wrote on last edited by
                    #10

                    [quote author="florent.revelut" date="1304326427"]Leon:
                    He's already got it (last -l, slightly differently formatted to take into account library):
                    @win32: LIBS += -L$$PWD/../../../libs/boost_1_44/stage/lib/ -llibboost_filesystem-vc100-mt -llibboost_system-vc100-mt@[/quote]

                    May be the "lib" part in the name should be removed as "suggested in similar topic in stackoverflow":http://stackoverflow.com/questions/2958137/cannot-not-find-library-files-in-eclipse-cdt

                    Cheers,
                    Leon

                    http://anavi.org/

                    1 Reply Last reply
                    0
                    • F Offline
                      F Offline
                      florent.revelut
                      wrote on last edited by
                      #11

                      oh, true... It always confuse me between visual and gcc, which sometime truncate names differently. At least, trying is cheap !

                      1 Reply Last reply
                      0
                      • G Offline
                        G Offline
                        golgobot
                        wrote on last edited by
                        #12

                        Thanks everyone. I started building boost using mingw before I went to work today. It should be done when I get home. I'll try that out and see if that works!

                        One last thing. Does anyone know the difference between libboost_system and boost_system? Is one static and the other dynamic?

                        1 Reply Last reply
                        0
                        • F Offline
                          F Offline
                          florent.revelut
                          wrote on last edited by
                          #13

                          some linkers (especially gnu) removes lib at the beginning of file and extension (.a usually). This tradition comes from unix world, it's not followed extensively in windows world (I don't think msvc acts like that). Basically, using gnu ld (thus mingwin), to link a lib named libtoto.a, you would use -ltoto

                          1 Reply Last reply
                          0
                          • L Offline
                            L Offline
                            leon.anavi
                            wrote on last edited by
                            #14

                            [quote author="golgobot" date="1304354643"]
                            One last thing. Does anyone know the difference between libboost_system and boost_system? Is one static and the other dynamic? [/quote]

                            This is a "qmake specific feature":http://doc.qt.nokia.com/latest/qmake-project-files.html#declaring-qt-libraries The familiar Unix-style notation for specifying libraries and paths can be used.

                            [quote author="florent.revelut" date="1304356117"]Basically, using gnu ld (thus mingwin), to link a lib named libtoto.a, you would use -ltoto

                            [/quote]

                            Excellent example :)

                            http://anavi.org/

                            1 Reply Last reply
                            0
                            • G Offline
                              G Offline
                              golgobot
                              wrote on last edited by
                              #15

                              Ok so I rebuild boost libraries using mingw. From my boost root I ran the command

                              @
                              bjam.exe --toolset=gcc --build-type=complete
                              @

                              This rebuilt the boost libraries using mingw. I ended up with a lot of libraries with ".a" extensions, the most important of which are libboost_system-mgw44-mt-1_44.a and libboost_filesystem-mgw44-mt-1_44.a. These are the two I want to link. My lib-includes in my .pro file looks like this below (the rest is the same as above)

                              @
                              win32: LIBS += -L$$PWD/../../../libs/boost_1_44/stage/lib/ -lboost_system-mgw44-mt-1_44 -lboost_filesystem-mgw44-mt-1_44

                              INCLUDEPATH += $$PWD/../../../libs/boost_1_44/stage/lib
                              DEPENDPATH += $$PWD/../../../libs/boost_1_44/stage/lib
                              @

                              the "lib" prefix is omitted, which is standard for including gcc libs.

                              When I compile I get the exact same error

                              bq.
                              C:\workspaces\qt\SIDController-build-desktop/../../../libs/boost_1_44/boost/system/error_code.hpp:214: undefined reference to boost::system::generic_category()' C:\workspaces\qt\SIDController-build-desktop/../../../libs/boost_1_44/boost/system/error_code.hpp:215: undefined reference to boost::system::generic_category()'
                              C:\workspaces\qt\SIDController-build-desktop/../../../libs/boost_1_44/boost/system/error_code.hpp:216: undefined reference to boost::system::system_category()' debug/serialsid.o:C:\workspaces\qt\SIDController-build-desktop/../../../libs/boost_1_44/boost/system/error_code.hpp:211: undefined reference to boost::system::system_category()'
                              debug/serialsid.o:C:\workspaces\qt\SIDController-build-desktop/../../../libs/boost_1_44/boost/asio/detail/impl/winsock_init.ipp:39: undefined reference to WSAStartup@8' debug/serialsid.o:C:\workspaces\qt\SIDController-build-desktop/../../../libs/boost_1_44/boost/asio/detail/impl/winsock_init.ipp:48: undefined reference to WSACleanup@0'
                              collect2: ld returned 1 exit status

                              After some more searching online I found a "post":http://stackoverflow.com/questions/1814548/boostsystem-category-defined-but-not-used that suggested I put this define statement

                              @
                              #ifndef BOOST_SYSTEM_NO_DEPRECATED
                              #define BOOST_SYSTEM_NO_DEPRECATED 1
                              #endif
                              @

                              Before my include. I ran the build and now I get only one error (and lots of warnings, but let's ignore those for now)

                              bq.
                              ......\libs\boost_1_44/boost/asio/error.hpp: In function 'const boost::system::error_category& boost::asio::error::get_system_category()':
                              ......\libs\boost_1_44/boost/asio/error.hpp:220: error: 'get_system_category' is not a member of 'boost::system'

                              I tried Googling that error, but came up with nothing. So I don't really feel closer to a solution. Just more confused than ever before. I look forward to seeing if anyone can help solve this mystery :)

                              1 Reply Last reply
                              0
                              • G Offline
                                G Offline
                                golgobot
                                wrote on last edited by
                                #16

                                I also feel like I should have to be placing hacky #defines throughout my code to get it to link properly.

                                1 Reply Last reply
                                0
                                • F Offline
                                  F Offline
                                  florent.revelut
                                  wrote on last edited by
                                  #17

                                  The linker is sensitive to the order in which you link : you must link file_system, then system. Basically, file_system relies on system, this latter must appear after on the command line.

                                  Could you please paste the exact command line that make is running ? Seems strange that it doesn't work...

                                  1 Reply Last reply
                                  0
                                  • G Offline
                                    G Offline
                                    golgobot
                                    wrote on last edited by
                                    #18

                                    The actual command that it is running is

                                    bq. g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-s -Wl,-subsystem,console -mthreads -Wl -o release\SIDController.exe release/main.o -L"c:\Qt\2010.05\qt\lib" -LC:/workspaces/qt/SIDController/../../../libs/boost_1_44/stage/lib/ -lboost_filesystem-mgw44-mt-1_44 -lboost_system-mgw44-mt-1_44 -lQtGui4 -lQtCore4

                                    It seems to be including the libraries for linking. I also switched the order of the libraries so boost_filesystem was first

                                    1 Reply Last reply
                                    0
                                    • G Offline
                                      G Offline
                                      golgobot
                                      wrote on last edited by
                                      #19

                                      And here is the complete output after a clean, then rebuild. Presented in two parts cause the max char limit for a post is 6000. This is easily reproducible using main.cpp shown at the beginning of the post in Windows 7 on a 64 bit processor. Could there be a 32 vs 64 bit issue?

                                      bq. Running build steps for project SIDController...
                                      Starting: "C:Qtqtcreator-2.1.84mingwbinmingw32-make.exe" clean
                                      C:/Qt/qtcreator-2.1.84/mingw/bin/mingw32-make -f Makefile.Release clean
                                      mingw32-make[1]: Entering directory C:/workspaces/qt/SIDController-build-desktop' del releasemain.o mingw32-make[1]: Leaving directory C:/workspaces/qt/SIDController-build-desktop'
                                      C:/Qt/qtcreator-2.1.84/mingw/bin/mingw32-make -f Makefile.Debug clean
                                      mingw32-make[1]: Entering directory C:/workspaces/qt/SIDController-build-desktop' del debugmain.o mingw32-make[1]: Leaving directory C:/workspaces/qt/SIDController-build-desktop'
                                      Could Not Find C:workspacesqtSIDController-build-desktopreleasemain.o
                                      Could Not Find C:workspacesqtSIDController-build-desktopdebugmain.o
                                      The process "C:Qtqtcreator-2.1.84mingwbinmingw32-make.exe" exited normally.
                                      Starting: "c:qt2010.05qtbinqmake.exe" C:workspacesqtSIDControllerSIDController.pro -r -spec win32-g++ "CONFIG+=release"
                                      The process "c:qt2010.05qtbinqmake.exe" exited normally.
                                      Starting: "C:Qtqtcreator-2.1.84mingwbinmingw32-make.exe"
                                      C:/Qt/qtcreator-2.1.84/mingw/bin/mingw32-make -f Makefile.Release
                                      mingw32-make[1]: Entering directory `C:/workspaces/qt/SIDController-build-desktop'
                                      g++ -c -O2 -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -I"......Qt2010.05qtincludeQtCore" -I"......Qt2010.05qtincludeQtGui" -I"......Qt2010.05qtinclude" -I"......libsboost_1_44" -I"......libsboost_1_44stagelib" -I"......Qt2010.05qtincludeActiveQt" -I"release" -I"..SIDController" -I"." -I"......Qt2010.05qtmkspecswin32-g++" -o releasemain.o ..SIDControllermain.cpp
                                      In file included from ......libsboost_1_44/boost/asio/basic_datagram_socket.hpp:18,
                                      from ......libsboost_1_44/boost/asio.hpp:20,
                                      from ..SIDControllermain.cpp:3:
                                      ......libsboost_1_44/boost/asio/detail/config.hpp:59:5: warning: #warning Please define _WIN32_WINNT or _WIN32_WINDOWS appropriately.
                                      ......libsboost_1_44/boost/asio/detail/config.hpp:60:5: warning: #warning For example, add -D_WIN32_WINNT=0x0501 to the compiler command line.
                                      ......libsboost_1_44/boost/asio/detail/config.hpp:61:5: warning: #warning Assuming _WIN32_WINNT=0x0501 (i.e. Windows XP target).
                                      In file included from ......libsboost_1_44/boost/asio/detail/win_iocp_handle_service.hpp:281,
                                      from ......libsboost_1_44/boost/asio/detail/win_iocp_serial_port_service.hpp:26,
                                      from ......libsboost_1_44/boost/asio/serial_port_service.hpp:26,
                                      from ......libsboost_1_44/boost/asio/basic_serial_port.hpp:29,
                                      from ......libsboost_1_44/boost/asio.hpp:24,
                                      from ..SIDControllermain.cpp:3:
                                      ......libsboost_1_44/boost/asio/detail/impl/win_iocp_handle_service.ipp: In constructor 'boost::asio::detail::win_iocp_handle_service::overlapped_wrapper::overlapped_wrapper(boost::system::error_code&)':
                                      ......libsboost_1_44/boost/asio/detail/impl/win_iocp_handle_service.ipp:49: warning: dereferencing type-punned pointer will break strict-aliasing rules
                                      In file included from ......libsboost_1_44/boost/asio/ip/address_v6.hpp:227,
                                      from ......libsboost_1_44/boost/asio/ip/address.hpp:22,
                                      from ......libsboost_1_44/boost/asio.hpp:46,
                                      from ..SIDControllermain.cpp:3:
                                      ......libsboost_1_44/boost/asio/ip/impl/address_v6.ipp: In constructor 'boost::asio::ip::address_v6::address_v6()':
                                      ......libsboost_1_44/boost/asio/ip/impl/address_v6.ipp:37: warning: missing braces around initializer for 'in6_addr::<anonymous union>'
                                      ......libsboost_1_44/boost/asio/ip/impl/address_v6.ipp:37: warning: missing braces around initializer for 'u_char [16]'
                                      ......libsboost_1_44/boost/asio/ip/impl/address_v6.ipp: In static member function 'static boost::asio::ip::address_v6 boost::asio::ip::address_v6::loopback()':
                                      ......libsboost_1_44/boost/asio/ip/impl/address_v6.ipp:259: warning: missing braces around initializer for 'in6_addr::<anonymous union>'
                                      ......libsboost_1_44/boost/asio/ip/impl/address_v6.ipp:259: warning: missing braces around initializer for 'u_char [16]'
                                      In file included from ......libsboost_1_44/boost/asio/ip/detail/endpoint.hpp:139,
                                      from ......libsboost_1_44/boost/asio/ip/basic_endpoint.hpp:20,
                                      from ......libsboost_1_44/boost/asio.hpp:49,
                                      from ..SIDControllermain.cpp:3:
                                      ......libsboost_1_44/boost/asio/ip/detail/impl/endpoint.ipp: In constructor 'boost::asio::ip::detail::endpoint::endpoint(int, short unsigned int)':
                                      ......libsboost_1_44/boost/asio/ip/detail/impl/endpoint.ipp:60: warning: missing braces around initializer for 'in6_addr::<anonymous union>'
                                      ......libsboost_1_44/boost/asio/ip/detail/impl/endpoint.ipp:60: warning: missing braces around initializer for 'u_char [16]'

                                      1 Reply Last reply
                                      0
                                      • G Offline
                                        G Offline
                                        golgobot
                                        wrote on last edited by
                                        #20

                                        Part 2

                                        bq. g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-s -Wl,-subsystem,console -mthreads -Wl -o releaseSIDController.exe release/main.o -L"c:Qt2010.05qtlib" -LC:/workspaces/qt/SIDController/../../../libs/boost_1_44/stage/lib/ -lboost_filesystem-mgw44-mt-1_44 -lboost_system-mgw44-mt-1_44 -lQtGui4 -lQtCore4
                                        mingw32-make[1]: Leaving directory C:/workspaces/qt/SIDController-build-desktop' release/main.o:main.cpp:(.text+0xda): undefined reference to WSAStartup@8'
                                        release/main.o:main.cpp:(.text+0xff): undefined reference to boost::system::generic_category()' release/main.o:main.cpp:(.text+0x109): undefined reference to boost::system::generic_category()'
                                        release/main.o:main.cpp:(.text+0x113): undefined reference to boost::system::system_category()' release/main.o:main.cpp:(.text+0x138): undefined reference to boost::system::system_category()'
                                        release/main.o:main.cpp:(.text+0x142): undefined reference to boost::system::system_category()' release/main.o:main.cpp:(.text+0x14c): undefined reference to boost::system::system_category()'
                                        release/main.o:main.cpp:(.text+0xa6): undefined reference to WSACleanup@0' release/main.o:main.cpp:(.text$_ZN5boost4asio6detail18win_tss_ptr_createEv[boost::asio::detail::win_tss_ptr_create()]+0x28): undefined reference to boost::system::system_category()'
                                        collect2: ld returned 1 exit status
                                        mingw32-make[1]: *** [releaseSIDController.exe] Error 1
                                        mingw32-make: *** [release] Error 2
                                        The process "C:Qtqtcreator-2.1.84mingwbinmingw32-make.exe" exited with code 2.
                                        Error while building project SIDController (target: Desktop)
                                        When executing build step 'Make

                                        1 Reply Last reply
                                        0
                                        • G Offline
                                          G Offline
                                          golgobot
                                          wrote on last edited by
                                          #21

                                          Ok I got it to compile, but it's not pretty at all.

                                          Firstly, I added the preprocessor definition mentioned above and documented "here":http://www.boost.org/doc/libs/1_44_0/libs/system/doc/reference.html to my .pro file, plus I also had to add a windows library called ws2_32, so my new .pro file looks like this (ignore how it's not cross platform)

                                          @
                                          DEFINES += BOOST_SYSTEM_NO_DEPRECATED

                                          win32: LIBS += -L$$PWD/../../../libs/boost_1_44/stage/lib/ -lboost_filesystem-mgw44-mt-1_44 -lboost_system-mgw44-mt-1_44 -lws2_32
                                          @

                                          After all that I was getting one more error

                                          bq.
                                          error.hpp:220: error: 'get_system_category' is not a member of 'boost::system'

                                          So I just commented that line out like so

                                          @
                                          inline const boost::system::error_category& get_system_category()
                                          {
                                          //return boost::system::get_system_category();
                                          }
                                          @

                                          At least it compiles. I have no idea if it runs yet or how important that line of code is. That method is defined inside an "#ifndef BOOST_SYSTEM_NO_DEPRECATED", so I don't know why that function uses a method that can potentially by ifdef'ed out.

                                          I'm used to running in Visual Studio where all this stuff just work.

                                          If anyone has a better way, PLEASE, let me know! Thanks for everyone's help so far.

                                          1 Reply Last reply
                                          0

                                          • Login

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