So let's say you want to build the Boost "Getting Started" examples and link to them using an Xcode project rather than building at the command line. You try the header-only option and it works fine.
But then you take the example source:
#include <boost/regex.hpp>
#include <iostream>
#include <string>
int main()
{
std::string line;
boost::regex pat( "^Subject: (Re: |Aw: )*(.*)" );
while (std::cin)
{
std::getline(std::cin, line);
boost::smatch matches;
if (boost::regex_match(line, matches, pat))
std::cout << matches[2] << std::endl;
}
}
And you do the following:
- Build the boost libraries using ./bjam install
- Open Xcode and create a new C++ command line utility project.
- Drag libboost_regex.dylib into the Products folder in the Groups & Files treeview (checking the option that allows it copy the file)
- Set the project options so that Header Search Paths points to the Boost include folder
- Build and Run the project!
Sadly, if you have the console open (Run | Console) you're going to see an error that it can't find the dylib:
dyld: Library not loaded: libboost_regex.dylib
Referenced from: /Users/matt/Documents/Boost/test/GettingStarted/build/Debug/GettingStarted
Reason: image not found
So, not knowing a better way to get Xcode to do this, you copy the dylib into your_project/build/debug/ and it runs! Hooray!
Detail-oriented person that you are, you type some stuff into standard in to try it out:
> Subject: foo bar baz
> foo bar baz
And then it segfaults.
Program received signal: “EXC_BAD_ACCESS”.
ACK!
But have no fear. I know what the problem is! And if nobody beats me to it, I'll post the solution after lunch.