cURL / Mailing Lists / curl-library / Single Mail


download an file on Mac OS X

From: Jürgen Keser <>
Date: Mon, 11 Feb 2013 17:26:36 +0100

Hi All,

we use Mac OS X 10.8 and Xcode 4.5.2. Here we try now to create our first simple (Cocoa Application) example with the
curl-library. We will download an file with this library and place the downloaded file to a special place. Enclosed I'll send you
the code we use until now. The curl_easy_setopt functions return all true, but the file will not be downloaded.
Also the Cocoa Application will cause an crash at the end. Is there anyone out there who can help me?

Thanks for any hints.

int main(void) {
    CURL *curl;
    FILE *fp;
    CURLcode res;
    char *url = "";

    curl = curl_easy_init();
    if (curl) {
        char outfilename[FILENAME_MAX] = "/OS X/ff";
        fp = fopen(outfilename,"curl-7.29.0.tar.gz");
        if(CURLE_OK == (res = curl_easy_setopt(curl, CURLOPT_URL, url))){
            NSAlert *alert = [[[NSAlert alloc] init] autorelease];
            [alert setMessageText:@"CURLOPT_URL OK"];
            [alert runModal];
        if(CURLE_OK == (res = curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1L))){
            NSAlert *alert = [[[NSAlert alloc] init] autorelease];
            [alert setMessageText:@"CURLOPT_NOPROGRESS OK"];
            [alert runModal];
        if(CURLE_OK == (res = curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L))){
            NSAlert *alert = [[[NSAlert alloc] init] autorelease];
            [alert setMessageText:@"CURLOPT_FOLLOWLOCATION OK"];
            [alert runModal];
        if(CURLE_OK == (res = curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp))){
            NSAlert *alert = [[[NSAlert alloc] init] autorelease];
            [alert setMessageText:@"CURLOPT_WRITEDATA OK"];
            [alert runModal];

        res = curl_easy_perform(curl);
    return 0;

Best regards,
Jürgen Keser

ComputerWorks GmbH
Schwarzwaldstraße 67
79539 Lörrach / Germany
Fon +49 (0)76 21 / 40 18 27
Fax +49 (0)76 21 / 40 18 18

Geschäftsführer: Carlos Pedro Lüthy, Jörg Adrian Weber
Amtsgericht Freiburg HRB 411648
Umsatzsteuer-ID DE 142396681

Distributor für Deutschland, Schweiz und Österreich:
Vectorworks - CINEMA 4D - Trimble SketchUp - FastTrack Schedule - NisusWriter und andere.

Diese Nachricht ist nur für den Empfänger bestimmt. Sie enthält persönliche vertrauliche Informationen. Der Inhalt darf an keinen anderen außer den Empfänger weitergeleitet werden. Unbefugte Empfänger werden gebeten, diese Vertraulichkeit zu wahren und den Absender sofort über einen Übertragungsfehler zu informieren.

This message is intended for the addressee only. It contains private and confidential information. The contents are not to be disclosed to anyone other than the addressee. Unauthorized recipients are requested to comply with the above and to inform the sender immediately of any errors in transmission by replying to this message and please delete it from your computer.

List admin:
Received on 2013-02-11