19
votes

I could not include boost in xcode. I used the build instructions from the Boost documentation and wrote the search paths in xcode /usr/local/lib and /usr/local/include.

Any help please !

4

4 Answers

40
votes

I have spent a long time trying to make this work. I could not make it work using the download from the Boost project homepage, so I used homebrew instead:

After homebrew is installed, I installed Boost using:

brew install boost 

or, if you don't have python installed, using:

brew install boost --without-python

Without the --without-python it would not install on my machine.

  1. In XCode (4.3.3), select the project file in the left sidebar (top most), and select it again in the project pane.
  2. Select the Build Settings tab, and select All.
  3. Under Search Paths, add the header search path /usr/local/Cellar/boost/1.49.0/include/ and check the box. The path should now show in the Build Settings.

Now, you can use:

#include <boost/regex.hpp>

or whatever you need from the Boost package.


In case you have boost already installed, use $ brew info boost to get the correct path:

boost: stable 1.60.0 (bottled), HEAD
Collection of portable C++ source libraries
https://www.boost.org/
/usr/local/Cellar/boost/1.60.0_1 (11,139 files, 436.5M) *
  Poured from bottle
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/boost.rb
11
votes

I followed henrikstroem's great post, like this:

Install via homebrew, took less than 3 minutes

mac:~ woz$ brew install boost
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/boost-1.57.0.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring boost-1.57.0.yosemite.bottle.tar.gz
🍺  /usr/local/Cellar/boost/1.57.0: 10572 files, 439M
mac:~ woz$

Create symlink in your homedir

mac:~ woz$ cd
mac:~ woz$ ln -s /usr/local/Cellar/boost/1.57.0 boost_1_57_0
mac:~ woz$ 

Inside Xcode refer to the just created symlink like this

Xcode build settings for boost

For the Header Search Paths use $(HOME)/boost_1_57_0/include

For the Library Search Paths use $(HOME)/boost_1_57_0/lib

11
votes

I'm using boost with Xcode 3.2.1 on mac os 10.6.8

I had problems with using boost and Xcode today, finally I managed to make it work so I hope this helps:

  1. download boost, I got the 1.52.0 today, untar it

  2. install boost:

    at first I couldn't do the ./bootstrap.sh, it stopped after the first few lines. After some googling, I got the answer, it was because when I installed Xcode a long time ago, for some reason I didn't check the “Unix development" in the install options. At this point, reinstall a newer version of Xcode and check the "unix development line"

    after that, the ./bootstrap and ./b2 install worked fine

  3. the lambda example:

    at this point, the first example should work fine, if it doesn't try adding /usr/local/include in the project settings/header search path

  4. using thread or something else that requires to be built

    threads require a specific dylib to work: libboost_system.dylib. on my system it was located in /usr/local/lib after the ./b2 install thingy

    in the left part of the GUI, you can right click anywhere and select Add Existing File

    if the file is hidden you can find a shortcut to get to usr/local/lib in the directory /Developer/SDKs/MacOSX10.6.sdk/usr/local

once the libboost_system.dylib does appear in the Groups and Files part of the GUI, it should work

6
votes
mic@mbp: ~/work $ brew install boost
mic@mbp: ~/work $ ls -l /usr/local/include/boost
lrwxr-xr-x  1 mic  wheel  36 Nov 27 01:06 /usr/local/include/boost -> ../Cellar/boost/1.56.0/include/boost

hi, I add /usr/local/include in Header Search Paths (with double click it, but Debug or other sub checks), then

#include <boost/asio.hpp>
#include <boost/date_time.hpp>

using namespace boost;

int main() {
    asio::io_service io;

    io.run();
    return 0;
}

worked, :D