[Solved] VSCode c++ task.json contains paths and libraries (2023)

c++ build visual studio code g++


solution 1

1. Am I configuring VSCode correctly?

Mostly. The fact that you have to specify the include paths twice (once inc_cpp_properties.jsonand again in a file describing your build) is unavoidable. In VSCode, the build system and editor don't understand each other and both need this information. With Visual Studio (without "code"), on the other hand, the paths would only have to be specified once; this is one of the advantages of using a "real" IDE. (But there are also downsides; I'm not trying to discourage you from using VSCode.)

However, I don't recommend using include paths inTasks.jsondirect. Instead there is usually a separate build system that can be invoked from the command line and thenTasks.jsonalso calls this command.

As a very common example, you could usegnu-doand replace the chainTasks.jsonwith this (untested!) Makefile:

test-sdl: main2.cpp g++ -g main2.cpp -ID:\\github\\dependencies\\SDL2-2.0.8\\include -LD:\\github\\dependencies\\SDL2-2.0.8\\ lib\\x64 -lSDL2main -lSDL2 -lopengl32 -o teste-sdl

it saysto dohow to buildtest-sdloutside ofprincipal2.cpp, that is, run theg++command shown. (I intentionally kept this makefile very simple, as the question isn't about makefiles - just keep in mind that a real makefile would break things up for better organization and the backslashes would probably need to be adjusted.)

In any case, yourTasks.jsonsimplify to:

{ // See https://go.microsoft.com/fwlink/?LinkId=733558 // for documentation on the tasks.json format "version": "2.0.0", "tasks": [ { "label “ : " build", "type": "shell", "command": "make", // <-- changed "args": [] // <-- changed } ], "group": { "kind " : " build", "is default": true }, "problemMatcher": "$gcc" }

This is better because important compilation information is not bundled into a file that only VSCode understands.

2. Can someone explain... includePath and navigate?

VSCode has two different systems for understanding C++ code. There is the old "tag parser" which usesnavigate.route, and the newer "Intellisense" that usesinclude path. At this point (2019-08-30, VSCode 1.37.1) I understand that basically everyone should be using the latest Intellisense system as it provides more accurate information and should be at least as mature. Consequently, you should be able to simplyignore navigate.route.

To make sure you are using Intellisense instead of Tag Parser, go to File → Settings → Preferences → C/C++ → "C_Cpp: Intelli Sense Engine" and make sure it is set to "Default" and not " Tag Parser". Note that these settings are saved inconfiguration.jsonrather thanc_cpp_properties.json.

solution 2

I also tried using libraries and at least now it works (I'm on Windows btw): in c_cpp_properties.json I have a reference to the include directory:

{ "Configurações": [ { "Nome": "Win32", "includePath": [ "C:\\ProgrammingLibraries\\SDL2-2.0.10\\include\\SDL2", "${workspaceFolder}\\src\ \include" ], "define": [ "_DEBUG", "UNICODE", "_UNICODE" ], "compilerPath": "C:\\mingw-w64\\x86_64-8.1.0-win32-seh-rt_v6-rev0 \\mingw64\\bin\\gcc.exe", "cStandard": "c11", "cppStandard": "c++17", "intelliSenseMode": "gcc-x64" } ], "versão": 4}

And in tasks.json I have a build and a link task and a task that runs both:

{ // Yes https://go.microsoft.com/fwlink/?LinkId=733558 // for Documentation in „tasks.json“ Format „version“: „2.0.0“, „tasks“: [ { „label “ : "Compiler", "type": "shell", "command": "g++", "args": [ "-c", "${workspaceFolder}\\src\\main.cpp", "-IC : \\ProgrammingLibraries\\SDL2-2.0.10\\include\\SDL2" ] }, { "label": "Linker", "type": "shell", "command": "g++", "args": [ "${workspace folder}\\main.o", "-o", "${workspace folder}\\bin\\HelloSDL.exe", "-LC:\\ProgrammingLibraries\\ SDL2-2.0.10\ \lib " , "-lmingw32", "-lSDL2main", "-lSDL2" ] }, { "label": "HelloSDL erstellen", "dependsOn": [ "Compiler", "Linker" ] , "group": { "kind ": "build", "is default": true } } ]}

solution 3

I'm also new to VS Code. Also, I've never created large C++ projects. At least for now, that's how I solved the building.(SEE BELOW)

I ended up doing this on mineTasks.json

"tasks": [ { "type": "shell", "tag": "g++ build active file", "command": "${workspaceFolder}/buildMysorcery.sh", "options": { "cwd": " /usr/bin" } },

(You cannot escape the inner spacesargumentProperty,https://github.com/Microsoft/vscode/issues/36733),

I removed the args property and set the command property to run a script (buildMysorcery.sh) which just works

#!/bin/bashg++ fullpathtodir/hello.cpp -Wall -g $(sdl2-config --cflags --libs) -o fullpathtodir/hello

replace thisfull path to saywith your ways

To share:


Similar videos on Youtube

[Solved] VSCode c++ task.json contains paths and libraries (1)

04 : 07

Include 3rd party c/cpp libraries in vscode (windows) msys2-gcc



(Video) How to Fix Include Path Error in C/C++ Files using Visual Studio Code

[Solved] VSCode c++ task.json contains paths and libraries (2)


Configure tasks.json to compile and run the *.c file opened in Visual Studio Code

Senhor Nguyen Ngoc


[Solved] VSCode c++ task.json contains paths and libraries (3)

05 : 04

Include path errors in VS code when running cpp code | 3 ways to solve it completely.



[Solved] VSCode c++ task.json contains paths and libraries (4)


Create a C++ project in VS Code

visual studio code


(Video) Include Path Error in VS Code | 100% Fixed

[Solved] VSCode c++ task.json contains paths and libraries (5)


Include path errors in VS Code | 100% solid



[Solved] VSCode c++ task.json contains paths and libraries (6)


How to fix include path error in C/C++ files with Visual Studio Code

increase my tool


[Solved] VSCode c++ task.json contains paths and libraries (7)


Setting up C++ development with Visual Studio Code on Windows 10 (VS Code)

programming knowledge


(Video) #include errors detected. update your include Path. How to fix this include path error in VS code !!

[Solved] VSCode c++ task.json contains paths and libraries (8)

author of

diego looking for

Hängt immer noch da...include int main(void){FILE *fp= fopen(./about_me.bin", "r");AboutMeNode *(&node);while (!eof(fp)){ fread(node , sizeof(Knoten), 1, fp); if (!feof(fp)) fprintf(stdout, "%c\t%x\n", nodo->datos, nodo->siguiente); } fclose(fp) ;}

Updated April 20, 2020


  • [Solved] VSCode c++ task.json contains paths and libraries (9)

    diego looking for more than 2 years

    IntelliSense uses c_cpp_properties.json >> includePath to find the autocomplete headers, but I realized that I still need to specify the include path inside task.json >> task >> args to compile.

    I found in the documentation that includePath is more or less the same path you would specify in "-I":

    The paths you specify for this setting are the same paths you would send to your compiler via the -I option. When parsing your source files, the IntelliSense engine appends these paths to the files specified by your #include directives when trying to resolve them. These paths are not searched recursively.*


    1. Am I configuring VSCode correctly by specifying all libraries and directories included in the build task arguments? Or should it be done differently?
    2. In other words, can someone explain what the difference between includePath and browse is? The explanation link is not entirely clear to me

    Here is an example of my c_cpp_properties.json:

    { "settings": [ { "name": "Win32", "includePath": [ "${workspaceFolder}/**", "D:/github/dependencies/SDL2-2.0.8/include" ], "define ": [ "_DEBUG", "UNICODE", "_UNICODE" ], "compilerPath": "C:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\ mingw64 \\bin\\g++.exe", "cStandard": "c11", "cppStandard": "c++17", "intelliSenseMode": "clang-x64", "browse": { "route": [ " ${workspaceFolder}/**" ] } } ], "Version": 4}

    e task.json:

    { // Acesse https://go.microsoft.com/fwlink/?LinkId=733558 // para a documentação para o formato „tasks.json“ „version“: „2.0.0“, „tasks“: [ { „label “ : "compilar", "tipo": "shell", "comando": "g++", "args": [ "-g", "main2.cpp", "-ID:\\github\\dependencies\\ SDL2 -2.0.8\\include", "-LD:\\github\\dependencies\\SDL2-2.0.8\\lib\\x64", "-lSDL2main","-lSDL2", "-lopengl32", " -o", "test-sdl" ] } ], "group": { "kind": "build", "isDefault": true }, "problemMatcher":"$gcc"}

    It's a simple question, but I'm new to VSCode (sorry).

    • [Solved] VSCode c++ task.json contains paths and libraries (10)

      imad more than 3 years

      I'm in the same situation and I have the same question. If you found an explanation for this, please share, thanks :)

    • [Solved] VSCode c++ task.json contains paths and libraries (11)

      (Video) Using Libraries in C++ (Static Linking)

      J-D3V more than 1 year

      This answer your question?#include errors detected in vscode

  • [Solved] VSCode c++ task.json contains paths and libraries (12)

    Francisco Rodo about 2 years

    I've tried this approach and it seems to work. The only problem I had is that if you declare all the dependencies in the last task they run in parallel, so sometimes you are linking .o files from previous builds. Instead, I suggest simply declaring the "linker" dependency in the last task and the "compiler" dependency in the "linker" task. That way, the linker waits for the compiler to finish its work.

the youngest

Why is a drop shadow PNG grainy in Flutter web app?

How to fix crashes detected by Google Play Store for Flutter app

Cupertino DateTime Picker breaks scroll behavior

Why does awk -F work for most letters but not the letter "t"?

Flutter change hover color and icon color but not working

How do I print to USB using Flutter Desktop and connect to the printer?

Critical issues have been reported with the following SDK versions: com.google.android.gms:play-services-safetynet:17.0.0

Flutter Dart: Get localized country name from country code

navigatorState é nulo ao usar pushNamed Navigation onGenerateRoutes de GetMaterialPage

Android SDK Manager Not Found - Flutter Doctor Error

Flutter Laravel push notification without using third parties like (Firebase, Onesignal, etc.)

How to change color of ElevatedButton when entering text in TextField

(Video) Compiling Multiple Files in VS Code


1. How to fix: Please update includePath. Cannot open source file on VSCode
2. Include c/cpp third party libraries in Vscode(windows) Msys2-Gcc
3. Launch.json Visual Studio Code Error - How to CORRECT It
(Junior Coder)
4. Include Path Error in VS code while running c cpp codes, unable to open stdio.h error in c vs code
(Cyber Warriors)
5. include errors detected. please update your includepath SOLVED visual studio code C and C++
(United Top Tech)
6. Visual Studio Code for C++ on Linux
(Top Shelf Technology)
Top Articles
Latest Posts
Article information

Author: Annamae Dooley

Last Updated: 03/28/2023

Views: 5778

Rating: 4.4 / 5 (45 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Annamae Dooley

Birthday: 2001-07-26

Address: 9687 Tambra Meadow, Bradleyhaven, TN 53219

Phone: +9316045904039

Job: Future Coordinator

Hobby: Archery, Couponing, Poi, Kite flying, Knitting, Rappelling, Baseball

Introduction: My name is Annamae Dooley, I am a witty, quaint, lovely, clever, rich, sparkling, powerful person who loves writing and wants to share my knowledge and understanding with you.