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.
  • 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
                  • M Offline
                    M Offline
                    mlong
                    wrote on last edited by
                    #22

                    bq. So I just commented that line out... At least it compiles.

                    I don't want this to devolve into a discussion of how to debug and patch boost, but from a general coding standpoint this doesn't seem like a very good idea at all. You now have a method that has no return value at all. While it may compile, it's just setting the stage for an unknown bug to pop up down the line if the get_system_category() method should be called somewhere down the line. At the very least, if you do go this route, you might consider putting some sort of warning debug message in that method and returning some known default value.

                    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
                    • R Offline
                      R Offline
                      raulgd
                      wrote on last edited by
                      #23

                      I know this is a very old post, but just for reference in case someone needs it in the future, the best way to get ASIO working with Qt is using it by itself instead of using the Boost integrated version.

                      Asio is a project on its own, and it doesn't need the Boost dependency in case you need to use it in something else (like Qt). Here's the project link in case someone needs it: "Think Async ASIO":http://think-async.com

                      I had a lot of issues until I was able to just get rid of Boost, which has things that I can already do with Qt, and in a much easier and cleaner way.

                      Thanks

                      Raul Guerrero
                      http://jimi.mx

                      1 Reply Last reply
                      0
                      • D Offline
                        D Offline
                        DanielS
                        wrote on last edited by
                        #24

                        Thanks a lot, i really helped me and save coutless hours of research!!!

                        1 Reply Last reply
                        0
                        • U Offline
                          U Offline
                          ut2007
                          wrote on last edited by
                          #25

                          [quote author="golgobot" date="1304398277"]

                          .....

                          @
                          #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)

                          ....

                          [/quote]

                          this worked for me .... thanks

                          also seen at "stackoverflow _ to be excluded as deprecated":http://stackoverflow.com/questions/1814548/boostsystem-category-defined-but-not-used

                          EDIT 1 :

                          Hi,

                          In case you are doing Ogre3D (OGRE 1.8.1 SDK for Visual C++ .Net 2010 (32-bit) ) then use QT5 32bit instead of the QT5 64bit version, it will pass.

                          I think it has been compiled (boost included) with 32bit thus i suppose i have to take src and recompile (using my 64bit) but thats another story where i wont go for now since OGRE 1.9 RC 1 SDK for Visual C++ .Net 2012 (64-bit) will be soon release on stable version.

                          Regards

                          EDIT 2 :

                          Downloaded Qt libraries 4.8.4 for Windows and configured my QT creator (the one coming with full QT5 and guess what .... Ogre3D is working like a charm when compiling on 4.8.4.

                          @
                          Qt 5.0.2 for Windows 32-bit (VS 2010, 485 MB)
                          Qt libraries 4.8.4 for Windows (VS 2010, 234 MB)
                          OGRE 1.8.1 SDK for Visual C++ .Net 2010 (32-bit)
                          @

                          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