I'm working on a c++ project in xcode and I need to use the boost.
So I download the boost with brew.
Then I install the boost with the command:
brew install boost
After this, I find that the boost is installed here:
/usr/local/Cellar/
Also, the link files of all head files of boost are found:
/usr/local/include/
The lib files of boost are found:
/usr/local/lib/
Then in my project in xcode:
Build Settings ---> Search Paths ---> Header Search Paths: /usr/local/include/
Build Settings ---> Search Paths ---> Library Search Paths: /usr/local/lib/
In my project, I try codes as below:
#include <boost/thread/thread_pool.hpp>
int main(int argc, const char * argv[])
{
return 0;
}
When I compile it, I get three errors below:
Undefined symbols for architecture x86_64:
"boost::system::system_category()", referenced from: ___cxx_global_var_init.2 in main.o "boost::system::generic_category()", referenced from: ___cxx_global_var_init in main.o ___cxx_global_var_init.1 in main.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
Then I add /usr/local/lib/
here:
Build Setting ---> Linking ---> Other Linker Flags.
Now I get only one error:
ld: can't map file, errno=22 file '/usr/local/lib/' for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
However, the code below works well:
#include <iostream>
#include <boost/version.hpp>
int main(int argc, const char * argv[]) {
std::cout << "Using Boost "
<< BOOST_VERSION / 100000 << "." // major version
<< BOOST_VERSION / 100 % 1000 << "." // minor version
<< BOOST_VERSION % 100 // patch level
<< std::endl;
return 0;
}