saiy2k saiy2k - 12 days ago 5
iOS Question

Boost::Geometry (1.53) with iOS

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?

Answer

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.