PDA

View Full Version : Boost and Xcode




Nibbles
Mar 5, 2007, 12:23 AM
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

configure
make
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.



amnesiak
Mar 5, 2007, 12:57 AM
try sudo make install

it will ask for a password.put in your password and see if that works.

Nibbles
Mar 6, 2007, 11:33 AM
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);
thrd.join();
return 0;
}


Errors I am getting

[11:28:18 Robin@Byte ~/Desktop]\>gcc 1.cc
/usr/bin/ld: Undefined symbols:
__Unwind_Resume
boost::thread::join()
boost::thread::thread(boost::function0<void, std::allocator<boost::function_base> > const&)
boost::thread::~thread()
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::ios_base::Init::Init()
std::ios_base::Init::~Init()
std::cout
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
___gxx_personality_v0
collect2: ld returned 1 exit status
[11:28:20 Robin@Byte ~/Desktop]\>

darkwing
Mar 6, 2007, 01:22 PM
Add -lboost to your gcc line.

Nibbles
Mar 8, 2007, 02:15 PM
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.

wrc fan
Mar 8, 2007, 02:26 PM
That didn't work. It still is complaining about the folder /usr/bin/ld. Should I have something in this folder?
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.

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.
That's really all that an admin user is... a member of the admin group which has sudo privileges.

darkwing
Mar 8, 2007, 02:32 PM
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.

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.

wittegijt
Mar 8, 2007, 04:01 PM
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.

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!

Wittegijt

Nibbles
Mar 8, 2007, 06:59 PM
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


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. ;)