PDA

View Full Version : Can I use libcurl with xcode?




macmee
Nov 3, 2009, 07:16 PM
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!



lloyddean
Nov 3, 2009, 07:30 PM
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.

macmee
Nov 3, 2009, 08:00 PM
If you've got Xcode installed then 'curl.h' is already available as expected. Not 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.

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:(

angelwatt
Nov 3, 2009, 08:10 PM
Try,
#include <curl/curl.h>
(http://www.sunran.com/upload-your-pictures-to-twitpic-using-clibcurl/)

macmee
Nov 3, 2009, 08:18 PM
Try,
#include <curl/curl.h>
(http://www.sunran.com/upload-your-pictures-to-twitpic-using-clibcurl/)

That works, thanks :).

Is there a tutorial for compiling these libraries? I'd like to install WxWidgets so I can create a GUI for my application.

edit: Ah, I'm getting linker errors:
http://macmee.com/screenshots/Screen_shot_2009-11-03_at_10.21.02_PM-20091103-222114.png

kainjow
Nov 3, 2009, 08:39 PM
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.

macmee
Nov 3, 2009, 08:48 PM
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.

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.

kainjow
Nov 3, 2009, 09:13 PM
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.

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.

macmee
Nov 4, 2009, 05:27 AM
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.

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

lloyddean
Nov 4, 2009, 11:00 AM
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'.