CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Dec 2008
    Posts
    10

    Download the contents of a URL.

    How can i download the contents of a URL using c/c++? Preferably on windows. I have already tried libcurl on linux, but i cant get it to work on windows. Any more ideas or suggestions?

  2. #2
    Join Date
    Apr 2005
    Posts
    107

    Re: Download the contents of a URL.

    Use (or take a look at the source code of) wget. There is a Windows version.

  3. #3
    Join Date
    Dec 2008
    Posts
    10

    Re: Download the contents of a URL.

    Quote Originally Posted by rdrast View Post
    Use (or take a look at the source code of) wget. There is a Windows version.
    Ok you can download the contents of a URL with wget but they are saved in a file. I would like to assign them to a string so that i can use them later on, instead of opening the file etc...

  4. #4
    Join Date
    Dec 2008
    Posts
    10

    Re: Download the contents of a URL.

    Any more suggestions? (Has anyone succeeded in installing curl and curlpp on windows? )

  5. #5
    Join Date
    Jan 2009
    Posts
    1,689

    Re: Download the contents of a URL.

    I use curl, you shouldn't need to install anything, you just need the library, which you can get ont he website. Make sure you download libcURL, not cURL, and download the Binary. It's GNU C, so it will work with your GNU C or C++ out of the box.

  6. #6
    Join Date
    Dec 2008
    Posts
    10

    Re: Download the contents of a URL.

    Quote Originally Posted by ninja9578 View Post
    I use curl, you shouldn't need to install anything, you just need the library, which you can get ont he website. Make sure you download libcURL, not cURL, and download the Binary. It's GNU C, so it will work with your GNU C or C++ out of the box.
    Ok, i downloaded libcurl binary and tried compiling an example that is on the site("simple.c").
    I included the path of curl.h like this <curl/curl.h>, but it didnt work , so i used "curl/curl.h".
    But i got a bunch of errors:
    Code:
    In file included from simple.c:2:
    curl/curl.h:35:61: curl/curlbuild.h: No such file or directory
    In file included from curl/curl.h:36,
                     from simple.c:2:
    curl/curlrules.h:80:4: #error "CURL_SIZEOF_LONG definition is missing!"
    In file included from curl/curl.h:36,
                     from simple.c:2:
    curl/curlrules.h:81: error: syntax error before "Compilation_aborted_CURL_SIZEOF_LONG_is_missing"
    curl/curlrules.h:85:4: #error "CURL_TYPEOF_CURL_SOCKLEN_T definition is missing!"
    curl/curlrules.h:90:4: #error "CURL_SIZEOF_CURL_SOCKLEN_T definition is missing!"
    curl/curlrules.h:95:4: #error "CURL_TYPEOF_CURL_OFF_T definition is missing!"
    curl/curlrules.h:100:4: #error "CURL_FORMAT_CURL_OFF_T definition is missing!"
    curl/curlrules.h:105:4: #error "CURL_FORMAT_CURL_OFF_TU definition is missing!"
    curl/curlrules.h:110:4: #error "CURL_FORMAT_OFF_T definition is missing!"
    curl/curlrules.h:115:4: #error "CURL_SIZEOF_CURL_OFF_T definition is missing!"
    curl/curlrules.h:120:4: #error "CURL_SUFFIX_CURL_OFF_T definition is missing!"
    curl/curlrules.h:125:4: #error "CURL_SUFFIX_CURL_OFF_TU definition is missing!"
    curl/curlrules.h:142: error: syntax error before "typedef"
    curl/curlrules.h:144: error: `CURL_SIZEOF_LONG' undeclared here (not in a function)
    curl/curlrules.h:154: error: `curl_off_t' undeclared here (not in a function)
    curl/curlrules.h:154: error: `CURL_SIZEOF_CURL_OFF_T' undeclared here (not in a function)
    curl/curlrules.h:164: error: size of array `__curl_rule_03__' is negative
    curl/curlrules.h:174: error: `curl_socklen_t' undeclared here (not in a function)
    curl/curlrules.h:174: error: `CURL_SIZEOF_CURL_SOCKLEN_T' undeclared here (not in a function)
    curl/curlrules.h:184: error: size of array `__curl_rule_05__' is negative
    In file included from simple.c:2:
    curl/curl.h:191: error: syntax error before "curl_off_t"
    Did i do something wrong?

  7. #7
    Join Date
    Dec 2008
    Posts
    10

    Re: Download the contents of a URL.

    Finally i managed to link the necessary libraries and compile my programs. Thank you everyone for your advice!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured