Using the Curl Library

Source: Internet
Author: User

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
  1. #include  " curl/curl.h "   
  2. #pragma  comment (lib, " Ws2_32.lib ")   
  3. #pragma  comment  ( lib, " Libcurl.lib " )   
  4. #pragma  comment  ( lib, " Ws2_32.lib " )   
  5. #pragma  comment  ( lib, " Winmm.lib " )   
  6. #pragma  comment  ( lib, " Wldap32.lib " )   
  7. int Main ()
  8. {
  9. CURL *curl;
  10. Curlcode Res;
  11.     curl = curl_easy_init ();   
  12.     if   ( curl )    
  13. {
  14. Curl_easy_setopt (Curl, Curlopt_url,
  15.             " http://www.baidu.com "  );   
  16. res = curl_easy_perform (curl);
  17. Curl_easy_cleanup (curl);
  18. }
  19. }

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.