C++ with curl using netbeans -


i need write c++ code download webpage, know need curl, im using mac osx have libcurl in /usr/include/curl. when compile code error :

#include <stdio.h> #include <curl/curl.h>  int main(void) {   curl *curl;   curlcode res;   curl = curl_easy_init();   if(curl) {    curl_easy_setopt(curl, curlopt_url, "http://example.com");    /* example.com redirected, tell libcurl follow redirection */     curl_easy_setopt(curl, curlopt_followlocation, 1l);   /* perform request, res return code */     res = curl_easy_perform(curl);   /* check errors */    if(res != curle_ok)     fprintf(stderr, "curl_easy_perform() failed: %s\n",           curl_easy_strerror(res));      /* cleanup */     curl_easy_cleanup(curl);  }  return 0; } 

here error:

  "/usr/bin/make" -f nbproject/makefile-debug.mk qmake= subprojects= .clean-conf    rm -f -r build/debug     rm -f dist/debug/gnu-macosx/cppapplication    clean successful (total time: 54ms)   undefined symbols 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   "_curl_global_cleanup", referenced from:      _main in main.o   "_curl_global_init", referenced from:      _main in main.o   ld: symbol(s) not found architecture x86_64   collect2: ld returned 1 exit status   make[2]: *** [dist/debug/gnu-macosx/cppapplication] error 1   make[1]: *** [.build-conf] error 2   make: *** [.build-impl] error 2   build failed (exit value 2, total time: 264ms) 

you should add curl library in project settings: project properties - build - linker. seems added path headers need add library linked after compilation stage.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -