Pages

Friday, January 25, 2013

Undefined symbols for architecture x86_64

I'm trying to run following code in mac os x mount lion (64 bit) but the curl library is not designed for same.

Please help how can i run this

 

C++ Application Code

 

#include

#include

#include

#include

size_t write_data(void *ptr, size_t size, size_t nmemb, FILE *stream) {

    size_t written;

    written = fwrite(ptr, size, nmemb, stream);

    return written;

}

 

int main() {

    std::string tempname = "temp";

    CURL *curl;

    CURLcode res;

    curl = curl_easy_init();

    if(curl) {

        FILE *fp = fopen(tempname.c_str(),"wb");

        curl_easy_setopt(curl, CURLOPT_URL, "http://www.google.com");

        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);

        curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);

        res = curl_easy_perform(curl);

        curl_easy_cleanup(curl);

        fclose(fp);

        fp = fopen(tempname.c_str(),"rb");

        fseek (fp , 0 , SEEK_END);

        long lSize = ftell (fp);

        rewind(fp);

        char *buffer = new char[lSize+1];

        fread (buffer, 1, lSize, fp);

        buffer[lSize] = 0;

        fclose(fp);

        std::string content(buffer);

        delete [] buffer;

    }

}

 

Error:

 

Undefined symbols for architecture x86_64:

  "_curl_easy_cleanup", referenced from:

      _main in main.o

  "_curl_easy_init", referenced from:

      _main in main.o

  "_curl_easy_perform", referenced from:

      _main in main.o

  "_curl_easy_setopt", referenced from:

      _main in main.o

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)


View the original article here

0 comments:

Post a Comment