curl - C++ Codeblocks + libcurl ends up with link errors -
hi c++ beginner , wanted learn http requests... picked curl because have experience using before php. downloaded version curl website c:\libs
win64 x86_64 7zip 7.51.0 binary ssl ssh viktor szakáts 1.81 mb
this i've done far on codeblocks:
under global compiler settings/search directories/compiler, added path: c:\libs\curl-7.51.0-win64-mingw\include\curl
under global compiler settings/search directories/linker, added path: c:\libs\curl-7.51.0-win64-mingw\lib
under global compiler settings/linker settings, added paths: c:\libs\curl-7.51.0-win64-mingw\lib\libcurl.a c:\libs\curl-7.51.0-win64-mingw\lib\libcurldll.a
-under global compiler settings/compiler settings, box checked before: have g++ follow c++11 standard... (no idea if matters or not...)
also, because desperate copied contents of c:\libs\curl-7.51.0-win64-mingw c:\program files (x86)\codeblocks\mingw, step makes no sense me, found online tried...
now running code:
#include <cstring> #include <string> #include <iostream> #include <stdio.h> #include <curl.h> #include <easy.h> using namespace std; int main(){ curl* curl = curl_easy_init(); if(!curl){ cout << "error" << endl; }else{ cout << "good job!" << endl; curl_easy_cleanup(curl); } };
i getting errors:
undefined reference `_imp__curl_easy_init' undefined reference `_imp__curl_easy_cleanup' error: ld returned 1 exit status build failed: 3 error(s), 0 warning(s) (0 minute(s), 0 second(s))
for reason, including include curl/curl.h not work, way works including curl.h, same easy.h
any advice appreciated! in advance!
you're linking static libcurl (on windows) without having -dcurl_staticlib
added cflags
when build application.
that is, must define curl_staticlib
before curl headers included.
described in curl faq item link errors when building libcurl on windows
Comments
Post a Comment