Use the Curl Library under Windows:
To http://curl.haxx.se/under a curl source down, the source code is compiled with VC6, I VS2005 under the compilation, incredibly only a warning.
The implementation code for curl is placed in the dynamic library, the dynamic library is statically compiled to generate Libcurl.lib, and then the "Include/curl" folder under the Curl source directory is copied to its own project (1).
Figure 1
Next you can call the Curl library directly, here is a simple example of online search:
[CPP]View Plaincopy
- #include " curl/curl.h "   
- #pragma comment (lib, " Ws2_32.lib ")   
- #pragma comment ( lib, " Libcurl.lib " )   
- #pragma comment ( lib, " Ws2_32.lib " )   
- #pragma comment ( lib, " Winmm.lib " )   
- #pragma comment ( lib, " Wldap32.lib " )   
- int Main ()
- {
- CURL *curl;
- Curlcode Res;
- curl = curl_easy_init ();
- if ( curl )
- {
- Curl_easy_setopt (Curl, Curlopt_url,
- " http://www.baidu.com " );
- res = curl_easy_perform (curl);
- Curl_easy_cleanup (curl);
- }
- }
Tip: When compiling the sample program in VS2005, you will be prompted with "LNK2001: unresolved external characters", as follows (reference: http://www.cnblogs.com/zdxster/archive/2011/01/27/1945877.html):
1. Add dependent libraries to the project: Additional dependencies, input----Properties
Note that the Debug configuration uses the Libcurld.lib
2, join the Pre-compilation option: Project----Properties->c/c++, preprocessor---preprocessor, put; Building_libcurl; Http_only copy it in (be careful not to lose ";" )
Using the Curl Library