#Cannot include curl.h on windows 10

20 messages · Page 1 of 1 (latest)

little kelp
#

I have just started to learn c by doing an old project from python. However I need to get weather data from a website and found curl. I did the first two commands for the vcpkg quick start, then followed the curl commands and running "curl -help" in cmd returns a bunch of commands. VS code autofills "curl/curl.h" but when attempting to compile with mingw64 gcc, it throws an error. The code is just includes

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

and outputs "curl/curl.h: No such file or directory"

thin whaleBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

cunning tartan
#

you need to point the compiler to the path where curl.h is located

little kelp
#

how do i do that?

cunning tartan
#

-I /path/to/curl.h

little kelp
#

would you know how to add that argument to vscode?

#

oh i got it

#

in case anyone else needs help with it i did

#include <C:/Users/Username/src/vcpkg/vcpkg/installed/x86-windows/include/curl/curl.h>
```but when i try to actually use it theres a bunch of "undefined reference to ..."
cunning tartan
#

you need to link the libcurl library

little kelp
#

im sorry im just trying everything i can think of

little kelp
heavy galleon
#

You have to specify the option -I C:/Users/Username/src/vcpkg/vcpkg/installed/x86-windows/include

#

And then specify the option -L C:/Users/Username/src/vcpkg/vcpkg/installed/x86-windows/lib

#

With I think -lcurl or smt like it

little kelp
#

like this?

"args": [
    "-fdiagnostics-color=always",
    "-g",
    "${file}",
    "-I C:\\Users\\Username\\src\\vcpkg\\vcpkg\\installed\\x86-windows\\include",
    "-L C:\\Users\\Username\\src\\vcpkg\\vcpkg\\installed\\x86-windows\\lib",
    "-lcurl",
    "-o",
    "${fileDirname}\\${fileBasenameNoExtension}.exe",
],
zinc perch
#

Remove the space after -I and -L or make those separate strings in the array

little kelp
#

so i reinstalled where libcurl was because the "Username" after users has a space (Like "Users\User name\src") and i thought it might be messing it up. It is installed in C: now and output the following after following the above instruction:

C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\src\vcpkg\installed\x86-windows\lib/libcurl.lib when searching for -lcurl
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\src\vcpkg\installed\x86-windows\lib/libcurl.lib when searching for -lcurl
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lcurl: No such file or directory
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\src\vcpkg\installed\x86-windows\lib/libcurl.lib when searching for -lcurl
little kelp
#

ok i found out its because i didnt have the 64 bit version of curl and the program now compiles, thanks for the help!

#

!solved