views:

3004

answers:

5

Hi everyone! I've recently got acquainted with Boost library and I'd like to use it in my Xcode project. But sadly there is no HowTo or FAQ on how to do it :(

What's the sequence of actions to build and use Boost libraries in Xcode?

Thanks in advance :)

+1  A: 

I don't know how to use Boost from XCode (I'm not a Mac programmer), but building boost is usually done through their own build tool, bjam.

They have a guide to building boost here, and you can download the latest version of bjam here

Once it is built, you reference it from Xcode the same way you would any other library. The boost/include should be added to your include path, and the libraries in boost/lib can be referenced for the boost libs that require it.

jalf
You need to follow the instructions for building on UNIX.
ceretullis
Already tried bjam. It didn't help :(
"didn't help"? What do you mean by that?
jalf
I mean it didn't build boost. There were some strange errors...
+2  A: 

For most of the boost libraries, there's nothing to build, it's all in header files. The remainder of the instructions are here.

rlbond
That does not describe how to build a program with Boost in XCode. It only describes how to build the library itself.
Sergiy Byelozyorov
+1  A: 

To build boost on a mac, follow the unix variants getting started page (http://www.boost.org/doc/libs/1_39_0/more/getting_started/unix-variants.html). You won't use Xcode directly to perform the build, but once complete you can add the boost include paths and dylib's to your Xcode project.

equackenbush
+4  A: 

The easiest way I've found to do it is to install MacPorts, then you can install/build Boost via a single command:

sudo port install boost

Plus you get similar access to other open source software. The only downside I've found is that, like any other package management system, they are not always up to date with the latest version.

Ferruccio
A: 

Thanks everyone for your help!

Building Boost seems to be not so trivial. I managed to use boost in my Xcode project by adding "/Users/Nick/Desktop/boost_1_38_0" to Header Search Paths in Xcode project preferences.

#include <boost/shared_ptr.hpp>
#include <iostream.h>
#include <iterator>
#include <algorithm>

   int main()
   {
      boost::shared_ptr<int> myPtr (new int (1));
      cout << *myPtr;
   return 0;
   }

This simple programm compiled :)

Generally, you should edit your question when adding more information, rather than putting it in an answer. Answers are shown sorted by rep, so it quickly becomes impossible to figure out the order in which they should be read if answers depend on others. And if you want to say "thank you", a comment usually suffices, and is more visible since it's shown directly after the question or answer you're commenting on. :)Anyway, glad you got it working. But I'm if you didn't manage to compile boost, you won't be able to use the boost libs that aren't header-only.
jalf
unfortunately, the regex sample program won't compile if you just dump it into a new XCode project. There are some compatibility issues for debug builds. i've posted more information on this issue in another question. [http://stackoverflow.com/questions/1882571/how-do-i-build-the-boost-getting-started-examples-using-xcode]
Matthew Lowe