Installing Boost (and failing miserably)

Discussion in 'Mac Programming' started by uselessn00b, Nov 1, 2013.

  1. uselessn00b macrumors newbie

    Joined:
    Nov 1, 2013
    #1
    I know I am doing something profoundly stupid, but ...

    So I installed the boost libraries, I thought I did it correctly but I am not getting g++ to compile the test program correctly at the end, so ... obviously not.

    Here is the flow of events. I downloaded boost_1_55_0b1.tar.bz2 from source forge

    in the terminal I unpacked with:
    Code:
    tar -xzf boost_1_55_0b1.tar.bz2
    entered the directory that this created:
    Code:
    cd boost_1_55_0b1
    ran the bootstrap setup:
    Code:
    ./bootstrap.sh --prefix=/usr/local
    ran the boost compile:
    Code:
    ./b2
    It identified I was on OSX and started to run its darwin compile. This took forever as it compiled over 1000 interfaces, failed on 4 (but it didn't seem all that bothered by them) and skipped 8. Seems like a reasonable install and it it seemed as happy as I was about this (which was acceptably happy).

    Then I ran the final install
    Code:
    ./b2 install
    And it seemed happy with how all the files were relocated and whatnot.

    So I pasted in a pre-made boost demo/test file the "boost/format.hpp" library into an empty text file and saved it as sample_userType.cpp (exact code here: http://www.boost.org/doc/libs/1_44_0/libs/format/example/sample_userType.cpp )

    but when I try to compile the test file:
    Code:
    g++ sample_userType.cpp
    I get a ton of errors, starting with the most important (and only real one):
    Code:
    sample_userType.cpp:16:28: error: boost/format.hpp: No such file or directory
    ... and all of the rest of the errors were obvious dangling definitions problems for various things defined the header file, format.hpp, and thus there is no reason to list them here as they are effectively meaningless.

    So ... any idea what embarrassingly idiotic thing have I done now? (thanks in advance.)
     
  2. mrichmon macrumors 6502a

    Joined:
    Jun 17, 2003
    #2
    You have not told g++ to search for header files in your boost install location. Try:

    Code:
    g++ -I/usr/local/include sample_userType.cpp
    The above assumes that the boost headers are installed into "/usr/local/include/boost".

    For more complex boost code you might also need to specify the library location "-L/usr/local/lib" and whichever boost libs you are using with "-l" arguments.
     
  3. uselessn00b thread starter macrumors newbie

    Joined:
    Nov 1, 2013
    #3
    Thanks, unfortunately I am still struggling here.

    Checking the actual install locations of the key header files with the pwd command reveals that the actual final header files can be found at:
    /usr/local/boost_1_54_0/boost

    I have now tried:
    Code:
    g++ -I/usr/local/ sample_userType.cc
    g++ -I/usr/local/boost_1_54_0 sample_userType.cc
    g++ -I/usr/local/boost_1_54_0/boost sample_userType.cc
    and for all of them the first error is now always of the form:
    Code:
    i686-apple-darwin10-g++-4.2.1: –I:<path/typed/above> No such file or directory
    followed by the old:
    Code:
    sample_userType.cc:16:28: error: boost/format.hpp: No such file or directory
    and then the usual string of gibberish due to missing dependencies.

    is this like an access or privilege issue? I can't really rationalize that as I managed to install in that location last night and I seem to be able to play around freely with stuff in that directory.

    Any thoughts?
     
  4. uselessn00b thread starter macrumors newbie

    Joined:
    Nov 1, 2013
    #4
    NEVER MIND!!!

    Yep, I was being dumb as hell and it was a permissions issue.

    I restarted, deleted everything involving boost on my computer (many instances at this point as I have now tried a few times.), and redownloaded the tarball from Source Forge freshly.

    I tried everything again exactly as before EXCEPT I replaced:
    Code:
    ./b2 install
    with
    Code:
    sudo ./b2 install
    Apparently the boost install is so accommodating and soft on errors or warnings that it will just plod through gracefully doing the best that it can (which is always still a lot, enough to convince me things were going perfectly fine), then finish up with a curtsy, pirouette, and flitted off stage weightlessly on toe-point after a very convincing performance. Even without the sudo it still compiled and installed a ton of stuff to the correct directory while flopping out seemingly endless amounts of positive and encouraging updates during the 15 minute process.

    Its all good now though, sorry to bother and thanks for your help mrichmon.

    The world is once again safe from idiocy ... but for how long?
     
  5. mrichmon macrumors 6502a

    Joined:
    Jun 17, 2003
    #5
    Have you considered using macports to get your boost install? The macports recipe for boost is kept up to date with boost releases. And if you are getting deeper into programming on OS X you will probably need other tools that are available via macports.
     

Share This Page