Apple Event: May 7th at 7 am PT

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

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 <iostream>

#include <string>

#include <curl/curl.h>

#include <stdio.h>

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)

Posted on Jan 25, 2013 1:46 AM

Reply
Question marked as Best reply

Posted on Jan 25, 2013 6:54 AM

Well, libcurl is a fat binary, so it does have the 64-bit version available on 10.8. So I guess the first question is, are you actually linking to libcurl?

9 replies

Undefined symbols for architecture x86_64

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