Thread: Using boost::asio

  1. #1
    Registered User
    Join Date
    Mar 2016
    Posts
    203

    Using boost::asio

    Earlier I'd asked re using the Boost that comes with nuwen distro:
    How to use the boost that comes with nuwen_distro?
    Since above post I've been able to use most of the Boost libraries successfully but am encountering a problem with boost::asio while trying to run the very first, simple program, example 32.1, from here:
    Chapter 32. Boost.Asio - I/O Services and I/O Objects
    getting error messages captured here:
    C:\>g++ -o test test.cpp C:\Users\ADMINI~1\AppData\Local\Temp\ccbxlVTy.o:te st.c - Pastebin.com

    It seems I'm missing some (combination of) headers, namespaces and/or macros any suggestions re how to fix these would be received gratefully. Many thanks,

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    37,534
    All those errors are linker errors, not compiler errors.
    It means the linker can't find the libraries where all those symbols are declared.

    Study jcfuller's reply #5 for starters.
    You also need to figure out what name(s) your various boost libraries have.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Mar 2016
    Posts
    203
    Salem thanks, at least you've helped me put a name to my problem!
    Reading further into the Boost documentation Boost Getting Started on Windows - 1.64.0 it seems there are two types of Boost libraries (a) header only libraries, those that are working fine for me and (b) separately compiled libraries that must be built separately prior to linking this is probably where my problem lies
    Through the above link I'm currently stuck on section 5.2.1 Install Boost Build, specifically where it says
    1. Go to the directory tools\build\.
    since there is no such directory in the boost that comes with the nuwen distro of mingw which also ties in with your advice:
    You also need to figure out what name(s) your various boost libraries have
    .
    Anyways, I am well aware that this issue might be too open ended currently for this forum. I'll go back to watching some more youtube and see if I can break the problem into a smaller, tractable component before returning. Thanks again, Sean

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    37,534
    If you know where your boost header files are stored on the file system, you could always use "find files" in explorer to find where all .dll / .lib files are stored.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    If you're on Windows, I highly recommend downloading and using vcpkg along with CMake. vcpkg is a Linux-like package manager for C++ development on Windows and it's amazing, imo.

  6. #6
    Registered User
    Join Date
    Mar 2016
    Posts
    203
    Salem, John – thanks for your replies
    Salem: nuwen-distro-boost didn't ship Boost.Build which includes the bootstrap.bat file (required in 5.1 here: Boost Getting Started on Windows - 1.64.0) So I downloaded Boost.Build and the batch file bootstraps the build engine fine. However the program b2 within Boost.Build is still unable to the find bootstrap.jam no matter in which (sub) directory I specified it. The error messages are on the following lines:
    Code:
    C:\MinGW7.1\MinGW\include\boost\boost-build>b2 install --prefix="C:\mingw7.1\mingw\build-boost"
    Unable to load Boost.Build: could not find build system.
    ---------------------------------------------------------
    C:\MinGW7.1\MinGW\include\boost\boost-build\boost-build.jam attempted to load the build system by invoking
        'boost-build ../src/kernel ;'
    but we were unable to find "bootstrap.jam" in the specified directory
    or in BOOST_BUILD_PATH (searching C:\MinGW7.1\MinGW\include\boost\boost-build\../src/kernel).
    Please consult the documentation at 'http://www.boost.org'.
    John (and Salem): the way I'm thinking of proceeding now is (a) install MSVS-17 (as this is a prerequisite even for vcpkg) (b) download Boost from it's website (not nuwen distro) as it promises 'to install a complete Boost distribution, (c) try and follow 5 and 6 from here: Boost Getting Started on Windows - 1.64.0 while staying within the MSVS Command Prompt as this seems to be well-explained in the documentation though how it'll play out in real life only time will tell

  7. #7
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    My only comment is this:

    Quote Originally Posted by sean_cantab
    C:\Users\ADMINI~1\AppData\
    Are you logging into your computer as Administrator? By doing this, and being on the internet, you're basically begging for malware to infect your computer. It would be a very good idea to create a limited user for yourself, and only elevate permissions when you actually need to.
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

  8. #8
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    Are you making sure that you're specifying your toolset to gcc?

  9. #9
    Registered User
    Join Date
    Mar 2016
    Posts
    203
    Are you making sure that you're specifying your toolset to gcc?
    I'd if I could reach 5.2.2 'Identify Your Toolset' from here: Boost Getting Started on Windows - 1.64.0 but the problems I highlighted in previous post relate to 5.2.1 'Install Boost.Build' where the commands are sans toolset:
    Code:
    1. Go to the directory tools\build\. 
    2. Run bootstrap.bat 
    3. Run b2 install --prefix=PREFIX where PREFIX is the directory where you want Boost.Build to be installed 
    4. Add PREFIX\bin to your PATH environment variable.
    Specifically, my problem arises at step 3 of 4 above

  10. #10
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    Hmm, unfortunate.

    Does this link maybe help? MinGW-w64 - for 32 and 64 bit Windows / Wiki2 / Building Boost

  11. #11
    Registered User
    Join Date
    May 2009
    Posts
    3,688
    Quote Originally Posted by sean_cantab View Post
    I'd if I could reach 5.2.2 'Identify Your Toolset' from here: Boost Getting Started on Windows - 1.64.0 but the problems I highlighted in previous post relate to 5.2.1 'Install Boost.Build' where the commands are sans toolset:
    Code:
    1. Go to the directory tools\build\. 
    2. Run bootstrap.bat 
    3. Run b2 install --prefix=PREFIX where PREFIX is the directory where you want Boost.Build to be installed 
    4. Add PREFIX\bin to your PATH environment variable.
    Specifically, my problem arises at step 3 of 4 above
    Did you or did you NOT specify gcc in step "2. Run bootstrap.bat" ?

    This is per the directions posted above.
    Quote Originally Posted by MutantJohn View Post
    Hmm, unfortunate.

    Does this link maybe help? MinGW-w64 - for 32 and 64 bit Windows / Wiki2 / Building Boost

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  12. #12
    Registered User
    Join Date
    Mar 2016
    Posts
    203
    John, Tim: I'm away from base until end July. Upon return I shall pick this one up again and let you know. In the meantime, many thanks for the additional heads-up. Regards, Sean

  13. #13
    Registered User
    Join Date
    Mar 2016
    Posts
    203
    Did you or did you NOT specify gcc in step "2. Run bootstrap.bat" ?
    Tim: Now I've done so:
    Code:
    C:\MinGW7.1\MinGW\include\boost\boost-build>bootstrap.bat gcc
    This does the bootstrapping, albeit with couple of warnings I don't recall seeing earlier: Bootstrapping the build engine execnt.c: In function 'maxline': execnt.c:523:1 - Pastebin.com
    However, the problem at next step
    Code:
    C:\MinGW7.1\MinGW\include\boost\boost-build>b2 install --prefix=C:\MinGW7.1\MinGW\include\boost\boost-build\boost_prefix
    remains unchanged and I'm getting the same error message posted in #6 above though I've saved copies of both bootstrap.jam and Jamroot.jam in this folder
    John: I had a look at your link - it requires downloading Boost separately (not using the one that comes with the nuwen distro of MinGW that I'm using) and (almost) takes me back to the lines of my thinking also outlined in #6:
    ... I'm thinking of proceeding now is (a) install MSVS-17 (as this is a prerequisite even for vcpkg) (b) download Boost from it's website (not nuwen distro) as it promises 'to install a complete Boost distribution, ...
    . This is indeed my preferred option but I'll wait till I can get another laptop as the current one is used extensively for work and I don't want MSVS-17 on it as it requires a lot of space
    Thanks
    Last edited by sean_cantab; 08-04-2017 at 12:29 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Boost.Asio's io_service and event handling
    By Chris87 in forum C++ Programming
    Replies: 12
    Last Post: 02-06-2016, 02:32 PM
  2. Converting From Boost::Asio::streambuf to a string
    By EverydayDiesel in forum C++ Programming
    Replies: 2
    Last Post: 01-07-2016, 11:26 AM
  3. Boost Asio and asynchronous I/O
    By Elysia in forum C++ Programming
    Replies: 9
    Last Post: 06-19-2011, 07:51 PM
  4. Open a serial port asynchronously with boost asio?
    By TriKri in forum C++ Programming
    Replies: 2
    Last Post: 05-16-2010, 12:33 PM
  5. Boost ASIO
    By PetrolMan in forum C++ Programming
    Replies: 0
    Last Post: 04-10-2009, 03:24 PM

Tags for this Thread