Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

C CURL ld: symbol(s) not found

I am trying to write a cli application using libcurl. I am getting this error and I have been unable to find a solution. Would someone please help me out here?


wes-imac:RR Ticket Watcher wes_dean$ gcc -o build/Test.app -I/opt/local/include -L/opt/local/lib -lcurl -lidn -lssl -lcrypto -lssl -lcrypto -lz source/*

source/main.c:7: warning: ‘write_callback_func’ used but never defined

Undefined symbols for architecture x86_64:

"_write_callback_func", referenced from:

_main in ccBWsrR4.o

ld: symbol(s) not found for architecture x86_64

collect2: ld returned 1 exit status


I have tried the -m32 option as well. I get the same error, only for a 32 bit architecture.


The tutorial that I am using says to include the curl/types.h header file, but this is the result when I do that.


wes-imac:RR Ticket Watcher wes_dean$ gcc -o build/Test.app -I/opt/local/include -L/opt/local/lib -lcurl -lidn -lssl -lcrypto -lssl -lcrypto -lz source/*

source/main.c:6:24: error: curl/types.h: No such file or directory


I have installed XCode with the Command Line Tools. I am running OS 10.8.2 and doing all development from the terminal.





#include <stdio.h>

#include <string.h>

#include <stdlib.h>

#include <curl/curl.h>

#include <curl/easy.h>

#include <curl/types.h>



size_t static write_callback_func (void *buffer, size_t size, size_t nmemb, void *userp);



main (argc, argv, envp)

int argc;

char *argv[], *envp[];

{

CURL *curl;

CURLcode res;

char *response;



char url[255];



if (argc > 1) {

strcpy(url, argv[1]);

}



curl = curl_easy_init();

if (curl) {

curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);

curl_easy_setopt(curl, CURLOPT_URL, url);

curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback_func);

curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);



res = curl_easy_perform(curl);

if (res != CURLE_OK) {

fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));

}

curl_easy_cleanup(curl);

}



printf("%s", response);



printf("\n");



return 0;

}

OS X Mountain Lion (10.8.2)

Posted on Jan 15, 2013 5:40 AM

Reply
8 replies

C CURL ld: symbol(s) not found

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.