Question

I want to use Boost::Geometry Library in my iOS Project. After a day of several attempts which are in vein, I am here at SO.

Since Geometry is a Header only library, my belief is binaries are not required and just adding the *.hpp files would suffice. Am I right?

Here is what I have done:

  1. Downloaded Boost 1.53.0
  2. Extracted the boost root folder to libs/boost folder. So path of boost root is project/libs/boost/boost (which contains geometry among others)
  3. Added new boost folder to xcode
  4. In build / target, set the Header Search Path to
    • "$(PROJECT_NAME)/../libs/boost"
    • "$(PROJECT_NAME)/libs/boost"
    • "$(PROJECT_NAME)/../libs/boost/boost"
    • "$(PROJECT_NAME)/libs/boost/boost"
  5. Got following compiler errors:
    • #include "boost/[geometry]/geometry.hpp" thrown "boost/geometry.hpp file not found"
    • #include "geometry.hpp" throws errors "boost/geometry/core/cs.hpp file not found" in geometry.hpp

Here is my project structure:

proj
 |--- classes
 |--- ios
 |--- libs
 |      |--- cocos2dx
 |      |--- CocosDenshion
 |      +--- boost
 +--- res

What am I missing?

Was it helpful?

Solution

I successfully integrated not just Boost::Geometry but the whole Boost library now. Here are the right steps to be followed:

  • Downloaded Boost 1.53.0
  • Extracted the boost root folder to libs/boost folder. So path of boost root is project/libs/boost/boost (It need not be part of the project, It can be elsewhere. Boost files will not be added to xcode, but will be referred by proper setting of Header Search Path)
  • In build / target, set the Header Search Path to boost folder, in my case it is, $(PROJECT_NAME)/../../libs/boost
  • Headers can then be added like #include <boost/geometry.hpp>

Since Boost::Geometry is a Header only Package, this works fine. But for packages requiring compilation, different approach is to be done.

OTHER TIPS

While you can add the whole boost repository as the accepted answer to your project, this is going to take a long time to compile.

The more robust and decoupled approach is to use static libraries.

For this you can use the ofxiOSBoost static libraries and headers:

(works for iOS 6, iOS 7, iOS 8 + )

Releases for Boost 1.57.0 libc++ (c++11), libstdc++, build scripts included as well

https://github.com/danoli3/ofxiOSBoost

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top