Skip navigation

C CURL ld: symbol(s) not found

887 Views 8 Replies Latest reply: Jan 24, 2013 11:56 PM by ashishverma RSS
Wesley212 Calculating status...
Currently Being Moderated
Jan 15, 2013 5:40 AM

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/ -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/ -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));






  printf("%s", response);






  return 0;


OS X Mountain Lion (10.8.2)


More Like This

  • Retrieving data ...

Bookmarked By (0)


  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.