0

Im on Windows and if I try to include curl in c i get the following error:
curl/curl.h: No such file or directory

I have curl installed and it runs fine in the command line.

Code:

#include <curl/curl.h>
#include <stdio.h>
#include <string.h>

int main(void) {
    return 0;
}

Full Error:

PS E:\Computer\Code> gcc .\test.c
.\test.c:1:10: fatal error: curl/curl.h: No such file or directory
    1 | #include <curl/curl.h>
      |          ^~~~~~~~~~~~~
compilation terminated.
  • First up: Check where `curl.h` ended up, then check that's in your include path. Remember that the command-line tool and the library with development headers can be two entirely different things. – tadman Apr 06 '23 at 18:58
  • What should i do concretely? (i have no clue about c, sry) – BlxckShadow Apr 06 '23 at 18:59
  • You might have the curl executable. You might even have the curl library. But that doesn't mean you have the curl header files needed to compile code to use the library. So first thing you need to do is figure out if you need to install these, or if you already have and the compiler can't find it. – ikegami Apr 06 '23 at 19:03
  • i have curl.h in C:\curl\include\curl\ – BlxckShadow Apr 06 '23 at 19:14
  • I would get rid of any existing MinGW and Curl installations and reinstall them from [MSYS2](https://stackoverflow.com/q/30069830/2752075). Then they're guaranteed to be compatible. – HolyBlackCat Apr 06 '23 at 20:36

1 Answers1

0
  • Make sure you have added the bin directory to your system's PATH environment variable. This will allow your system to locate the libcurl binaries when you compile and run your C program. eg: Downloaded files to a directory called, C:\curl. Then add the C:\curl\bin directory to your system's PATH environment variable.

  • Compile your C program with the -lcurl flag to link it with the libcurl library.

gcc test.c -lcurl