Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Include file not found in include directory" when directories contain environment variables #87

Closed
xtrium-lnx opened this issue Jun 29, 2016 · 17 comments

Comments

@xtrium-lnx
Copy link

Hi,
I'm trying to make the switch to vscode for a c++ project with multiple contributors. The project is currently developed on windows and current bug was only tested on this platform.

Since we're more than one, we've set up environment variables pointing to where our libraries' include files are.

When trying to add "${ZENVIRONMENT_PATH}/include" to the includePath of the project, vscode gives a "Include file not found in include directory" message on all includes from said path. This happens whether the environment variable is a system or a user one.

Directly using the absolute path of the folder to add to includes fixes the problem, but isn't viable for me.

@sridmad
Copy link
Member

sridmad commented Jun 30, 2016

Currently we are not expanding environment variables in includePath. Justin is looking at addressing the issue.

@jgoshi
Copy link
Member

jgoshi commented Jul 7, 2016

The fix is in the next release, version 0.8.0. We will resolve:

  1. Environment variables using the syntax ${var}
  2. '~' expansion to the user's home directory

@jgoshi jgoshi closed this as completed Jul 7, 2016
@xtrium-lnx
Copy link
Author

Awesome ! Thanks for the quick reaction :)

@Shivamnema
Copy link

Version 1.4.0
Commit 6276dcb0ae497766056b4c09ea75be1d76a8b679
Date 2016-08-04T16:49:32.489Z
Shell 0.37.6
Renderer 49.0.2623.75
Node 5.10.0
I'm using Ubuntu 16.04. I'm facing the similar issue. Please suggest the way out.

@jgoshi
Copy link
Member

jgoshi commented Aug 24, 2016

What is your cpptools version?

@laoshaw
Copy link

laoshaw commented Sep 16, 2016

0.9.1 I'm using on 16.04 ubuntu, all standard header files are showing "Include file not found in include directory" thus no auto-complete on those standard functions, e.g: #include <stdio.h> will have green-wave-icons underneath and when mouse-over it it says ""Include file not found in include directory"

@Shivamnema
Copy link

@jgoshi i'm using G++ 5.4.0.
@laoshaw Yeah. This is the same thing happening to me to.

@sridmad
Copy link
Member

sridmad commented Sep 16, 2016

@laoshaw , @Shivamnema05 can you share the includePath settings you are using?

@sridmad sridmad reopened this Sep 16, 2016
@Shivamnema
Copy link

@sridmad How to get that setting ?

@sridmad
Copy link
Member

sridmad commented Sep 16, 2016

it should be in c_cpp_properties.json under /path/to/the/root/folder/.VSCode. If the file is not there, see the section "Specifying Additional Include Directories for Better Symbol Support" at https://code.visualstudio.com/docs/languages/cpp

@Shivamnema
Copy link

@sridmad

{
"name": "Linux",
"includePath": ["/usr/include"],
"browse" : {
"limitSymbolsToIncludedHeaders" : true,
"databaseFilename" : ""
}
}

@Shivamnema
Copy link

Shivamnema commented Sep 18, 2016

I don't how. But my problem is fixed.

@jgoshi
Copy link
Member

jgoshi commented Sep 21, 2016

If you run into this again please reopen (or create a new issue).

@jgoshi jgoshi closed this as completed Sep 21, 2016
@itsaandy
Copy link

itsaandy commented May 6, 2017

Hi, I'm having the same problem. Except I'm using bash on windows. I'm getting the "Include file not found in include path" warning. I've tried adding the include path to both windows and linux settings:

Here's the windows settings:
{
"name": "Win32",
"includePath": [
"${workspaceRoot}",
"/mnt/c/Users/user/AppData/Local/lxss/rootfs/usr/include"
],
"defines": [
"_DEBUG",
"UNICODE"
],
"browse": {
"path": [],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
}

Here's the linux settings:
{
"name": "Linux",
"includePath": [
"${workspaceRoot}",
"/mnt/c/Users/user/AppData/Local/lxss/rootfs/usr/include",
"/usr/local/include",
"/usr/include"
],
"defines": [],
"browse": {
"path": [
"/usr/include",
"/usr/local/include"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
},

@sean-mcmanus
Copy link
Collaborator

sean-mcmanus commented May 8, 2017

@AdityaPokharel You need to add include paths to the browse.path setting. We should probably change the error message to better explain this. Originally, there was just a single includePath, which functioned like the current browse.path, but now the includePath is supposed to match the compiler include path settings, and the browse.path is more like the symbol path setting and is recursive and is supposed to include source files too.

@ndtreviv
Copy link

I've got v 1.20.1 for Mac and am still experiencing this problem.
I have my headers in an include directory, and have specified:

                "${workspaceRoot}",
                "${workspaceRoot}/include",

in both includePath and browse: { path [ areas of the c_cpp_properties.json file, and still it persists in telling me that it can't find the header files.

Can you give an example project layout and c_cpp_properties.json that will make this IDE happy?

@bobbrow
Copy link
Member

bobbrow commented Feb 23, 2018

If you rename you c_cpp_properties.json to something else (e.g. c_cpp_properties.json-old) and then run the "Edit Configurations..." command again, the extension will attempt to generate a new file with the correct paths filled in to match your Mac. If won't have ${workspaceRoot}/include, but it should have the system header paths, which is what I'm assuming you're missing based on your post.

If you continue to have issues, please open a new issue so we can track it. This issue is closed.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

9 participants