c++xcodelinkerheader-files

Using framework header files in Xcode for C++ project


Im having trouble to use Gecode (http://www.gecode.org/download.html) framework for my project.

  1. I downloaded and installed the framework. Now it can be found under

    /Library/Frameworks/gecode.framework

  2. I created a new "Command Line Tool" project, and selected "C++" for the type.

  3. Then I opened the Target of my project and added gecode.framework in Build Phases -> Link Binary With Libraries
  4. In Build Settings for the path i added following path for "Header Search Path" : /Library/Frameworks/gecode.framework
  5. Now i tried to build a sample code with following includes:

    #include <gecode/driver.hh>
    #include <gecode/int.hh>
    #include <gecode/minimodel.hh>
    

--> Xcode is complaining that file is not found.

I tried to compile in terminal with g++ and llvm-g++, it compiles without any warnings or errors


Solution

  • To make GeCode or any other framework work in Xcode you need to do the following.

    1. Install the framework (Obviously!! GeCode Link here)
    2. Open the project in Xcode
    3. Select the project file from the project navigator on the left side of the project window.

    Xcode Project window

    1. Under Linked Frameworks and Libraries, click the + sign.

    2. Select the framework from the list display or else click on Add Other if your framework is not found in the list.

    3. Press Command+Shift+G and enter the path directly. In my case for gecode it was /Library/Frameworks/ and then select the desired framework you want to include in your project and then press open.

    Framework path in Xcode

    1. Go back to you project file and press Command + r and Voila!! it should work.

    Cheers!!