Search code examples
iphonexcodeboostboost-thread

How to add boost thread library to an iPhone project?


I am trying to port an existing project to iPhone which needs Boost.Thread library, the project compiles without error but there are link errors:

"boost::thread::start_thread()", referenced from:
  boost::thread::thread<(anonymous namespace)::ReadThread::Function>((anonymous namespace)::ReadThread::Function, boost::disable_if<boost::is_convertible<(anonymous namespace)::ReadThread::Function&, boost::detail::thread_move_t<(anonymous namespace)::ReadThread::Function> >, boost::thread::dummy*>::type)in ChessEngine.o

How can I add the required thread libs to the Xcode project?

p.s. the boost lib is in: /usr/local/lib/libboost_thread-mt.a

EDIT (library found, but got architecture error):

Following Linking to Boost.Signals using Xcode, after adding /usr/local/lib in Library Search Path and -lboost_thread-mt in Other Linker Flags, the library is found. However, there are new errors and warnings:

ld: warning: in /usr/local/lib/libboost_thread-mt.dylib, file was built for unsupported file format which is not the architecture being linked (i386)

How can I have the lib working for iOS (4.0 or later)? Thanks!


Solution

  • I did some more searching and found this downloadable script that will build a multi-architecture iphone ready version of boost. Also check out this blog post about using it.