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"
],
...
}
Related
i am trying to use vscode and the arduino-cli. The extension is working correctly in veryfing and uploading the code to the board but it keeps highlighting arduino keywords (e.g.: digitalWrite) as errors, and as far as i can tell this should not happen.
I am going to attach the arduino.json, c_cpp_properties.json files in because i read that the problem may lay here.
arduino.json:
{
"sketch": "first.ino",
"configuration": "cpu=atmega2560",
"board": "arduino:avr:mega",
"port": "COM5"
}
c_cpp_properties.json
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "C:\\MinGW\\bin\\gcc.exe",
"cStandard": "c89",
"cppStandard": "c++98",
"intelliSenseMode": "windows-gcc-x86"
}
],
"version": 4
}
Have you tried adding the paths of all libraries your Arduino IDE program comes with? Notice the line with the forcedInclude instruction that points to the path of the Arduino.h file.
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"C:/Program Files (x86)/Arduino/hardware/arduino/avr/cores/arduino",
"C:/Program Files (x86)/Arduino/hardware/arduino/avr/libraries/EEPROM/src",
"C:/Program Files (x86)/Arduino/hardware/arduino/avr/libraries/HID/src",
"C:/Program Files (x86)/Arduino/hardware/arduino/avr/libraries/SoftwareSerial/src",
"C:/Program Files (x86)/Arduino/hardware/arduino/avr/libraries/SPI/src",
"C:/Program Files (x86)/Arduino/hardware/arduino/avr/libraries/Wire/src"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE",
"ARDUINO_AVR_UNO",
"ARDUINO_ARCH_AVR"
],
"compilerPath": "C:/Program Files (x86)/Arduino/hardware/tools/avr/bin/avr-gcc.exe",
"forcedInclude": [
"C:/Program Files (x86)/Arduion/hardware/arduino/avr/cores/arduino/Arduino.h"
],
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}
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:
I recently installed anaconda and added it to my visual studio code. I had previously installed C++
but now after setting up python interpreter on visual studio code i can't figure out how to switch back to my C++ compiler
Does anyone knows how to?
Edit:
My vs code folder looks like:
->.vscode
->settings.json (1)
->c_cpp_properties.json
->launch.json
->settings.json (2)
My launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(Windows) Launch",
"type": "cppvsdbg",
"request": "launch",
"program": "enter program name, for example ${workspaceFolder}/a.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"console": "externalTerminal"
}
]
}
My settings.json (2):
{
"code-runner.runInTerminal": true,
"workbench.colorTheme": "Abyss",
"C_Cpp.updateChannel": "Insiders",
"workbench.editorAssociations": {
"*.ipynb": "jupyter-notebook"
},
"notebook.cellToolbarLocation": {
"default": "right",
"jupyter-notebook": "right"
},
"notebook.lineNumbers": "on",
"python.analysis.completeFunctionParens": true,
"[cpp]": {
"editor.wordBasedSuggestions": false,
"editor.suggest.insertMode": "replace",
"editor.semanticHighlighting.enabled": true
}
}
Settings.json (1):
{
"python.pythonPath": "C:\\Users\\HP\\.conda\\envs\\myenv\\python.exe"
}
My c_cpp_properties file:
{
"configurations": [
{
"name": "Win32",
"browse": {
"databaseFilename": "",
"limitSymbolsToIncludedHeaders": true
},
"includePath": [
"${workspaceFolder}/**",
"C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64",
"C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin",
"C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/include",
"C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib",
"C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++",
"C:/Users/HP/AppData/Local/Programs/Python/Python39/Scripts"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/g++.exe",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64",
"compileCommands": ""
}
],
"version": 4
}
I think i have messed up my settings.json but i don't understand much about vs code yet so i can't figure out how to fixed it.
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.
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
}