C++ header that includes directory in xcode

Discussion in 'Mac Programming' started by lucasvickers, Nov 21, 2009.

  1. lucasvickers macrumors newbie

    Joined:
    Nov 21, 2009
    #1
    Hello,
    I am attempting to pull curlpp (libcurl c++ wrapper) into an xcode project.

    The library has include files such as:
    #include <curlpp/Easy.hpp>

    Which brings me to two questions.
    1 - Why would someone put the curlpp/ in the include?
    2 - How do I get this to work in xcode? I am able to pull the files in and I put them in a group called "curlpp", add them to the compiler search path, but when I attempt to build the curlpp/ is causing errors.

    Thanks,
    Lucas
     
  2. lloyddean macrumors 6502a

    Joined:
    May 10, 2009
    Location:
    Des Moines, WA
    #2
    It's likely its developer means for it to sit along side the CURL headers which on Mac OS X are at /usr/include/curl/curl.h. Being that this is a system header include path it is accessed with '#include <curl/curl.h>'.

    I don't recommend placing the 'curlpp' headers in the systems '/usr/include'. Instead if you're finding yourself using a good number of *nix libraries I'd suggest placing then in a common location on your system and then pointing at them using "Source Trees" panel of Xcodes Preferences.

    For instance I use Boost in some projects but like to use MacPorts which has a working Boost port. So I simply add an entry to the "Source Tree" panel.

    "Setting name" 'BoostHeaders', "Display Name" 'Boost Headers' and "Path" as '/opt/local/usr/include'.

    This carries across all Xcode projects with no need for me to set it up for each project.

    Check out the using Xcode Source Trees.
     
  3. lucasvickers thread starter macrumors newbie

    Joined:
    Nov 21, 2009
  4. Sander macrumors 6502

    Joined:
    Apr 24, 2008
    #4
    This is a form of namespacing. Suppose you use lots of libraries in your project, chances are that a file called "utilities.h" or "types.h" exists multiple times. If you add all directories for these libraries to your include path, the compiler will simply pick the first one it finds. If you only add the top level directories, you can discriminate between "onelibrary/types.h" and "anotherlibrary/types.h".
     
  5. lucasvickers thread starter macrumors newbie

    Joined:
    Nov 21, 2009
    #5
    I suppose the alternative is to not use such general names for header files.
    thanks for the input
     
  6. Sander macrumors 6502

    Joined:
    Apr 24, 2008
    #6
    Of course - but this trick works when you use other people's libraries.
     
  7. iShellac macrumors newbie

    Joined:
    May 28, 2010
    #7
    Could you please explain how you got it working? I'm struggling with the same thing. Have tried creating a Source Tree to no effect.
     
  8. lucasvickers thread starter macrumors newbie

    Joined:
    Nov 21, 2009
    #8
    This was a while ago I can't remember. I believe I add the curlpp and curlutils files into the 10.6 SDK for apple. All in all if you get the include paths specified in the project correctly it should work fine.
     
  9. iShellac macrumors newbie

    Joined:
    May 28, 2010
    #9
    I figured it out. Source Trees weren't the solution at all for me.

    I copied the curlpp and utilspp directories into my /usr/local/include directory, then went into my project build settings and added /usr/local/include to my Header Search Paths (making sure to check Recursive). Compiled fine after that.
     

Share This Page