简体   繁体   中英

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 :

在此处输入图像描述 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:

在此处输入图像描述

Consequently obtaining that error.

(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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM