Search code examples
c++curllibraries

Error after implementing 'curl': E1696 cannot open source file "curl/curl.h"


The title says it all. I'm using VS 2019 since as far as I can understand, curl is more used on VS 2019 rather than VS Code (correct me if I'm wrong). So my project has this structure:

── myproject
    ├── myproject
    │   ├── src
    │   │   ├── main.cpp
    │   ├── myproject.vcxproj
    │   ├── myproject.vcxproj.filters
    │   └── myproject.vcxproj.user
    ├── externals
    │   ├── curl [SUBMODULE]
    │   │   ├── include [THE INCLUDE DIRECTORY]
    │   │   │   ├─ ···
    │   │   ├── ···
    │   ├── ···
    ├── .git
    ├── .vs
    ├── .gitmodules
    ├── myproject.sln
  1. I added curl (see https://github.com/curl/curl) as a Git submodule in the folder ./externals/curl:

enter image description here 2. In my solution, I went to the project 'myproject' -> (Right Click) -> Properties -> C/C++ -> General -> Additional Include Directories and added the following line: $(SolutionDir)externals\curl\include -> Apply -> OK

  1. I went to ./src/main.cpp and pressed View Code (F7), then added the line #include "curl/curl.h". But even after doing steps 1 and 2, VS 2019 won't detect the curl headers:

enter image description here

Consequently obtaining that error.


Solution

  • (Thanks to @drescherjm)

    All you have to do is ensure you have applied the change in step #2 for all the configurations and platforms (go to the project 'myproject' -> (Right Click) -> Properties -> C/C++ -> General -> Additional Include Directories; in the top of the window, set 'Configurations' to "All Configurations" as well as 'Platforms' to "All Platforms"). See Image

    You may want to apply these Include Directories only to one (or a few) of the configurations and/or platforms, so once you're done just set that(those) configuration(s) on your Visual Studio IDE.