Boost and Xcode

Discussion in 'Mac Programming' started by Nibbles, Mar 4, 2007.

  1. macrumors newbie

    Apr 12, 2006
    I would like to get the Boost C++ libraries working in XCode. Has anybody done this or have some tips n how to do it? I download boost 1.33.1 and ran

    make install - this command seemed to have all errors on copying

    I am trying to run all of this as my normal user account I use all the time, but this account does not have admin rights. Do I need to run this under an account that has admin rights? Is there an easy way to install the boost libraries for command line compiling? I tried downloading the boost from the Fink libraries, but I couldn't find it.

    Thanks for the help.
  2. macrumors member


    Oct 13, 2006
    try sudo make install

    it will ask for a password.put in your password and see if that works.
  3. thread starter macrumors newbie

    Apr 12, 2006
    I got a little bit farther now, but I don't know if it installed correctly.

    I am trying to compile this simple program to test the boost library through terminal, but it is failing. Is there something I am missing with the boost install?

    Boost Thread Test Program
    #include <boost/thread/thread.hpp>
    #include <iostream>
    using namespace std;
    void hello()
    	cout << "Hello world, I'm a thread!" << endl;
    int main(int argc, char* argv[])
    	boost::thread thrd(&hello);
    	return 0;
    Errors I am getting
    [11:28:18 Robin@Byte ~/Desktop]\>gcc
    /usr/bin/ld: Undefined symbols:
    boost::thread::thread(boost::function0<void, std::allocator<boost::function_base> > const&)
    std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))
    std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)
    std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)
    vtable for __cxxabiv1::__pointer_type_info
    vtable for __cxxabiv1::__function_type_info
    collect2: ld returned 1 exit status
    [11:28:20 Robin@Byte ~/Desktop]\>
  4. macrumors 65816

    Jan 6, 2004
  5. thread starter macrumors newbie

    Apr 12, 2006
    That didn't work. It still is complaining about the folder /usr/bin/ld. Should I have something in this folder?

    Sorry I am not a unix expert. Also how do you add a non admin user to the sudoers list? Is there a file that I can edit or do I have make the user an admin user? I was only able to sudo when I did this.
  6. macrumors 65816

    wrc fan

    Jan 19, 2003
    In a world where LPs are made like pancakes
    It's not complaining about the folder as it isn't a folder. ld is an application located in /usr/bin (anything located in a folder called "bin" or "sbin" is an application. If you're not able to diagnose even a simple error message like this, I think you might want to take a step back and learn something about development under unix systems. For further reference, the problem is that it is not finding "__Unwind_Resume". A quick google search for that will give you lots of answers for solving it.

    That's really all that an admin user is... a member of the admin group which has sudo privileges.
  7. macrumors 65816

    Jan 6, 2004
    It isn't able to find your boost specific classes for some reason. I think I messed up. Try adding -lboost and -lboost_thread to your gcc line.
  8. macrumors member

    Feb 18, 2007
    That's the linker complaining. Try this:
    g++ -I/usr/local/include/boost-1_33_1 -L/usr/local/lib boost_test.cpp -lboost_thread -o boost_test

    Assuming you installed boost in the default directories. Use g++ for C++ code, not gcc. The second part of your errors is the stdc++ lib missing. And make sure the include and library paths are correct!

  9. thread starter macrumors newbie

    Apr 12, 2006
    Thanks that worked great! :) Now I need to figure out how to create a makefile so I won't have to remember all those commands. ;)

Share This Page