1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

Can I use libcurl with xcode?

Discussion in 'Mac Programming' started by macmee, Nov 3, 2009.

  1. macrumors 6502

    I downloaded libcurl and extracted it, and I see a lot of files like install-sh configure makefile reconf config.guess and so on. I just want to be able to open xcode, make a new c++ app, and be able to use #include <curl/curl.h> like the examples on the website. Can anyone show me how?:p

    Sorry if this is a stupid question, but I'm just learning C++ and xcode for the first time!
  2. macrumors 6502a

    If you've got Xcode installed then 'curl.h' is already available as expected. No need to install anything else.

    Now if you go ahead and install a newer version of 'curl' someplace on the system other than over the existing version (which I don't recommend myself) you'll need to do some extra work to point to the newer headers.
  3. macrumors 6502

    I just tried to do
    #include <string>  
    #include <iostream>  
      #include <curl.h>
    int main(int argc, char* argv[])  
    {  return 0;
    and it can't find curl.h. There are some more things like curl which I want to use such as WxWidgets so I can create a GUI for my applications, but I'm not sure how to install these either:(
  4. Moderator emeritus


  5. macrumors 6502

  6. Moderator emeritus


    Most likely it got installed into /usr/local/lib so you need to add the library into your Xcode project so it can link to it properly. Easiest way is to drag the file into the Frameworks group in Xcode.
  7. macrumors 6502

    I'm really new to XCode, but I can't find a folder called frameworks on the left side of my xcode project where it lists the folders.
  8. Moderator emeritus


    Ah, my bad. That doesn't show up if you make a Command Line Tool project.

    Try selecting in the menu bar Project > Add to Project. Then in the dialog, hit the keystroke Option-/ and in the window that shows type /usr/local/lib and hit Go. Then you can select the curl.a or whatever it's called to add to your project. Xcode should be smart enough to know what you selected and automatically link to it.
  9. macrumors 6502

    Thanks, I didn't know about the option / thing, but there wasn't a curl.h in usr/local/lib
  10. macrumors 6502a

    No, but there is 'libcurl.dylib' which is the library you need to link against to resolve your link errors.

    The header itself is at '/usr/include/curl/curl.h'.

Share This Page