Zak
Zak

Reputation: 12613

Adding boost include paths to the compiler on the Mac

I just finished installing Boost on OSX Mountain Lion, and I got this dialog...

The following directory should be added to compiler include paths:

/usr/local/boost_1_51_0

The following directory should be added to linker library paths:

/usr/local/boost_1_51_0/stage/lib

The Boost "Getting Started" page suggest this program:

#include <boost/lambda/lambda.hpp>
#include <iostream>
#include <iterator>
#include <algorithm>

int main()
{
    using namespace boost::lambda;
    typedef std::istream_iterator<int> in;

    std::for_each(
        in(std::cin), in(), std::cout << (_1 * 3) << " " );
}

Compiled with this script:

c++ -I /usr/local/boost_1_51_0 example.cpp -o example

Is there a way to add this include path in Linux/UNIX for Mac, so I don't have to always type the path when I'm compiling?

Upvotes: 0

Views: 1980

Answers (1)

HonkyTonk
HonkyTonk

Reputation: 2019

Short answer: Yes.

Long answer: You shouldn't do it.

Reason: If you add specific compiler flags to be used at all times, no matter what you are compiling, you will end up with situations where the wrong thing is included or linked against.

It is always a good thing to explicitly state the flags to be used in a makefile or on the command line and there are tools like pkg-config that can make this less troublesome and error prone.

Upvotes: 1

Related Questions