Home > Blockchain >  How to enable boost library in xcode
How to enable boost library in xcode

Time:01-29

I have a problem with adding boost library to my project in Xcode. It seems that some parts of boost work correctly but when I use some of them I get the following errors. Example- boost fiber library:

Undefined symbols for architecture arm64:
  "boost::fibers::future_category()", referenced from:
      std::make_error_code(boost::fibers::future_errc) in main.o
  "boost::fibers::condition_variable_any::notify_all()", referenced from:
      boost::fibers::condition_variable::notify_all() in main.o
  "boost::fibers::mutex::lock()", referenced from:
      std::__1::unique_lock<boost::fibers::mutex>::unique_lock(boost::fibers::mutex&) in main.o
  "boost::fibers::mutex::unlock()", referenced from:
      std::__1::unique_lock<boost::fibers::mutex>::unlock() in main.o
      std::__1::unique_lock<boost::fibers::mutex>::~unique_lock() in main.o
  "boost::fibers::wait_queue::empty() const", referenced from:
      boost::fibers::condition_variable_any::~condition_variable_any() in main.o
      boost::fibers::mutex::~mutex() in main.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

CodePudding user response:

The best way to install boost on a macOS from my experience is to install homebrew package manager. Then in a terminal enter brew install boost, this will install the boost library for you on your machine. To enable boost in Xcode open project then navigate to build setting from there select header search path and paste the location of the boost header files. (usually located in the usr/local/include) for the header and usually located in the usr/local/lib) for the library files. enter image description here


This should solve the majority of undefined symbol problems. Depends on your project, you might also want to add other libraries, such as libboost_context and libboost_filesystem to your project as well.

  •  Tags:  
  • Related