Thread: problems compiling C with libcurl headerfile

  1. #1
    Registered User sandeep080's Avatar
    Join Date
    Apr 2010
    Posts
    17

    Question problems compiling C with libcurl headerfile

    hi,
    I have installed libcurl3 in my ubuntu. But when i try to run the program using the command

    g++ sample.C -l curl

    It gives an error saying "curltest.c:2:23: fatal error: curl/curl.h: No such file or directory
    compilation terminated."

    i'd be glad if someone could help me out with this problem!

    Thanks in advance

    PS:
    The code i tried to run is..

    Code:
    #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");
        res = curl_easy_perform(curl);
     
        /* always cleanup */ 
        curl_easy_cleanup(curl);
      }
      return 0;
    }

  2. #2
    Registered User
    Join Date
    Jan 2010
    Posts
    412
    It's been a while since I last used ubuntu but I think the devel package for curl is called libcurl-dev

  3. #3
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    Quote Originally Posted by sandeep080 View Post
    It gives an error saying "curltest.c:2:23: fatal error: curl/curl.h: No such file or directory
    compilation terminated."
    Are you sure your path is setup correctly? These errors are usually pretty straightforward. Either the files are there or not.
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  4. #4
    Registered User sandeep080's Avatar
    Join Date
    Apr 2010
    Posts
    17
    Quote Originally Posted by AndrewHunter View Post
    Are you sure your path is setup correctly? These errors are usually pretty straightforward. Either the files are there or not.
    I'm not sure whether i have setup the path or not.. how do i know?? please help

  5. #5
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  6. #6
    Registered User sandeep080's Avatar
    Join Date
    Apr 2010
    Posts
    17
    Thanks everyone, i can compile the programs successfully.. i have some starting trouble..
    When i compile and run the problem, the program displays the whole html of the page i request to the standard output stream. but i dont find any explicit print statements.. how do i make the program not display it.. the libcurl documentation din help me much.. i want to redirect the html to a file stream.. im familiar with files in C.

  7. #7
    Registered User
    Join Date
    Jan 2010
    Posts
    412
    libcurl - curl_easy_setopt() - CURLOPT_WRITEDATA

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 03-30-2011, 10:39 AM
  2. Some Compiling Problems
    By mattnp12 in forum C Programming
    Replies: 9
    Last Post: 05-26-2010, 10:31 PM
  3. declaring a structure in another headerfile
    By ahming in forum C Programming
    Replies: 7
    Last Post: 04-05-2008, 04:39 AM
  4. Does anybody know how can we use Java to prepare a C HeaderFile
    By arvindkr_1999 in forum C++ Programming
    Replies: 8
    Last Post: 04-28-2004, 03:16 AM
  5. C Headerfile problems
    By hireintelligence in forum C Programming
    Replies: 1
    Last Post: 03-02-2002, 12:45 PM

Tags for this Thread