C++ in Visual Studio Code: Include path not found - visual-studio-code

I use Visual Studio code with the extensions "C/C++ for Visual Studio Code" (ms-vscode.cpptools) for developing simple C++ programs. I have added the configuration file cpp_properties.json to the .vscode subfolder to get intellisense support (see below). Unfortunately VS code does not honor the include path defined herein. I always get green swiggles under #include directives saying #include errors detected. Please update your includePath. ....
What's strange is, that the before mentioned error disappears when I select the correct configuration using the command C/Cpp: Select a configuration .... I have to repeat this command everytime I reopen the project. So obviously the include paths seems to be correct.
Is it possible to make VS Code or the CPP extension store the active configuration? Or is it at least possible to define a default configuration?
c_cpp_properties.json:
{
"configurations": [{
"name": "MinGW on Windows",
"includePath": [
"${workspaceRoot}",
"${MINGW_HOME}\\include\\c++\\7.1.0",
"${MINGW_HOME}\\include\\c++\\7.1.0\\x86_64-w64-mingw32",
"${MINGW_HOME}\\include\\c++\\7.1.0\\backward",
"${MINGW_HOME}\\lib\\gcc\\x86_64-w64-mingw32\\7.1.0\\include",
"${MINGW_HOME}\\include",
"${MINGW_HOME}\\x86_64-w64-mingw32\\include"
],
"defines": [],
"browse": {
"path": [
"${workspaceRoot}",
"${MINGW_HOME}\\include\\c++\\7.1.0",
"${MINGW_HOME}\\include\\c++\\7.1.0\\x86_64-w64-mingw32",
"${MINGW_HOME}\\include\\c++\\7.1.0\\backward",
"${MINGW_HOME}\\lib\\gcc\\x86_64-w64-mingw32\\7.1.0\\include",
"${MINGW_HOME}\\include",
"${MINGW_HOME}\\x86_64-w64-mingw32\\include"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
},
"intelliSenseMode": "clang-x64"
},
{
"name": "GCC on Linux",
"includePath": [
"${workspaceRoot}",
"/usr/include/c++/6",
"/usr/include/x86_64-linux-gnu/c++/6",
"/usr/include/c++/6/backward",
"/usr/lib/gcc/x86_64-linux-gnu/6/include",
"/usr/local/include",
"/usr/lib/gcc/x86_64-linux-gnu/6/include-fixed",
"/usr/include"
],
"defines": [],
"browse": {
"path": [
"/usr/include/c++/6",
"/usr/include/x86_64-linux-gnu/c++/6",
"/usr/include/c++/6/backward",
"/usr/lib/gcc/x86_64-linux-gnu/6/include",
"/usr/local/include",
"/usr/lib/gcc/x86_64-linux-gnu/6/include-fixed",
"/usr/include",
"${workspaceRoot}"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
},
"intelliSenseMode": "clang-x64"
}
],
"version": 2
}

Related

Setting up vscode with msys2 clang

I was trying to switch my Vscode from msys2 gcc to msys2 clang. I have downloaded clang according to the msys2 documentation provided. I have also followed the visual studio documentation for setting up clang. But my visual code fails to recognize iostream header.
I updated my environment path:
I also updated required include paths in my vs code configuration files:
cpp_properties:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceRoot}",
"C:/msys64/clang64/include",
"C:/msys64/clang64/include/**",
"C:/msys64/clang64",
"C:/msys64/clang64/include/c++/v1",
"C:/msys64/clang64/lib/clang/14.0.4/include",
"C:/msys64/clang64/lib/clang/14.0.4/include/**",
"${workspaceFolder}/**",
"C:/msys64/clang64/bin",
"C:/msys64"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.19041.0",
"compilerPath": "C:/msys64/clang64/bin/clang++.exe",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64",
"browse": {
"path": [
"C:/msys64/clang64/include",
"C:/msys64/clang64/include/**",
"C:/msys64/clang64/include/c++/v1",
"C:/msys64/clang64/lib/clang/14.0.4/include",
"C:/msys64/clang64/lib/clang/14.0.4/include/**",
"${workspaceRoot}",
"C:/msys64/clang64/bin",
"C:/msys64"
],"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
}
],
"version": 4
}
Still i keep getting the following error:

How to fix Linux paths created by CMake Tools in ".vscode\c_cpp_properties.json" in VSCode?

I am preparing to develop a cross-platform project with CMake and so I used Cmake Tools and it created following compilerPaths:
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c18",
"cppStandard": "c++20",
"intelliSenseMode": "clang-x64",
"configurationProvider": "ms-vscode.cmake-tools",
"compilerArgs": [],
"browse": {
"path": [
"${workspaceFolder}/**"
],
"limitSymbolsToIncludedHeaders": true
}
},
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.18362.0",
"compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.26.28801/bin/Hostx64/x64/cl.exe",
"cStandard": "c18",
"cppStandard": "c++20",
"intelliSenseMode": "msvc-x64",
"compilerArgs": [],
"browse": {
"path": [
"${workspaceFolder}/**"
],
"limitSymbolsToIncludedHeaders": true
}
}
],
"version": 4
}
In PROBLEMS tab I see Cannot find "\usr\bin\gcc". and that's obvious, because I am on Windows, but
the name values Linux and Win32 have some special meanings and
the paths have not been generated by me, but automatically so
I would expect the "PROBLEM" should not be there.
So how to correctly fix the "PROBLEM"?
You just need to switch the config.
On the bottom right it should say Linux (the name of the config).
Click on Linux and switch to Win32.
I got the same error on Windows when my config was set to Linux. When switching to the Win32 config I get no error.

sources assets files in js-debug missing with visual studio code on Apache Royale

I use visual studio code and setup it following theses instructions :
https://github.com/apache/royale-asjs/wiki/Visual-Studio-Code
Everythings worked fine.
For now I deleted bin folder in main project, and when launch debug, then bin and js-debug and others stuffs are right generated, but my assets dir with used jpg are not copied.
For exemple in the code I use <j:Image src="assets/logo.png" percentHeight="100"/> but the is no assets/logo.png in js-debug. So I must copy it manualy...
Here is my asconfig.json :
{
"compilerOptions": {
"targets": [
"JSRoyale"
],
"theme": "${royalelib}/themes/JewelTheme/src/main/resources/defaults.css",
//"html-template": "src/main/resources/jewel-example-index-template.html",
"source-map": true,
"source-path": [
"src"
],
},
"files":
[
"src/main/royale/App.mxml"
]
}
and tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"type": "actionscript",
"clean": true,
"problemMatcher": []
},
{
"label": "build",
"type": "actionscript",
"debug": true,
"problemMatcher": []
}
]
}
Could someone tell me how to copy assets folder automatically ?
thanks
Regards
Add to your asconfig.json file:
"copySourcePathAssets": true

ADD .lib file in visual studio code c++

I need to include jsoncpp in my visual studio code.
Is there any way to include .lib file in visual studio code?
this is my
c_cpp_properties.json
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/*",
"${workspaceFolder}/C++Script/Dependencies/include"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.16299.0",
"compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.12.25827/bin/Hostx64/x64/cl.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "msvc-x64"
}
],
"version": 4
}
I included json.h( although my compiler says it can't find the header file ) and I would like to include .lib file as well.
Can you tell me how to do that? I do know how to do this in visual studio. ( with liker )
c_cpp_properties.json is for Intellisense, you need to use tasks.json. Example:
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "cl.exe build active file",
"command": "cl.exe",
"args": [
"/Zi",
"/EHsc",
"/Fe:",
"${fileDirname}\\${fileBasenameNoExtension}.exe",
"${file}",
"/I",
"C:\\vcpkg\\installed\\x86-windows\\include"
],
...
}

includePath in VSCode w/ MSYS2

Try as I might, I simply cannot get VSCode to find ANY headers I've specified in includePath and browse->path. Here is my c_cpp_properties.json file. Surely VSCode should be able to find curses.h after this:
{
"configurations": [
{
"name": "MSYS2",
"includePath": [
"C:/msys64/mingw64/include/ncurses/"
],
"defines": [
"_DEBUG",
"UNICODE"
],
"compilerPath": "C:/msys64/mingw64/bin/gcc",
"intelliSenseMode": "clang-x64",
"browse": {
"path": [
"C:/msys64/mingw64/include/ncurses/"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
}
],
"version": 4
}
I've tried forward and backslashes in the pathnames. Nothing seems to work. I should mention that I'm using MSYS2/MinGW-w64.
I noticed in my own default 'c_cpp_properties.json' file that all path strings were using a double backslash.
"C:\\So\\Something\\Like\\This.exe"