Добавление MSVC 2017 в Qt
Я перепробовал слишком много вещей. У меня есть длинная история с главной проблемой Qt! Моя основная проблема: «тип компьютера модуля« x64 »конфликтует с целевым компьютером« x86 »», который появляется в консоли при сборке приложения Qt! Я собираюсь включить некоторые из вещей, которые я попробовал: — Попытался собрать из приложения Qt и Консоли. — Перепробовал все компиляторы, которые автоматически определяются из Qt. Есть и другие, но не нужно упоминать об остальном. В моих наборах по умолчанию большинство имен были в следующем порядке: «Qt 5.13.0 для 64/86-бит UWP (MSVC 2017)». Я думал, что это должен быть MSVC 2017, поэтому я попытался настроить MSVC 2017 (у меня MSVC 2019). Я нашел основную программу компилятора, которая называется «cl.exe». Я пошел в автоопределенные компиляторы Qt, я не нашел это! Я попытался добавить его, скопировав команды для qmake.exe и jom.exe из другого набора, который уже сделан для меня. Тем не менее, я поставил тип компилятора ‘custom’, потому что я не нашел MSVC. Это неправильно, и чем это отличается от других типов?
Моя следующая вещь, чтобы исправить (на самом деле попробовать) это:

Рисунок выше содержит путь к компилятору и путь к Make. Мне нужно найти инструмент Make path, я думаю, что он необходим, не так ли? Я попытался запустить программу без шага Make, ТОЛЬКО qmake step. Это привело меня к другой проблеме при запуске программы: «Произошла ошибка при попытке построить / развернуть вашу программу». Я правильно заполнил путь к компилятору, но я не знаю, как заполнить путь создания, я даже не знаю, что такое путь создания. Обратите внимание, что Qt не дает мне никакого результата, потому что путь создания не заполнен правильно!
Я надеюсь, что все описано и вся необходимая информация уже включена в рассказ выше! Спасибо за помощь. Я ценю все усилия по оказанию помощи мне.
2 ответа
Вы не можете добавить MSVC вручную в Qt Creator. Вам нужно, чтобы он был автоматически обнаружен.
Также меняется механизм обнаружения в зависимости от версии MSVC и версии Qt Creator. Поэтому убедитесь, что вы используете последнюю версию Qt Creator (на данный момент 4.9.2), чтобы убедиться, что все ваши установленные инструменты MSVC обнаружены.
Также, учитывая ваши комментарии, вы, кажется, путаете 64-битные и 32-битные.
x86 означает 32-разрядный, а amd64 означает 64-разрядный.
- x86 32-битный компилятор, который выдает 32-битный exe
- x86_amd64 32-битный компилятор, который выдает 64-битный exe
- amd64 64-битный компилятор, который выдает 64-битный exe
- amd_x86 64-битный компилятор, который выдает 32-битный exe
Поэтому, если вы хотите создавать 32-битные программы, вы можете использовать x86 или amd64_x86 . Если вы хотите создавать 64-битные программы, вы можете использовать amd64 или x86_amd64 .
Если в какой-то момент вы захотите скомпилировать Qt porgam, но Qt Creator не распознает ваш набор инструментов MSVC, у вас все еще есть решение:
- Откройте Qt 5.12.4 (MSVC 2017 64-bit) из меню Пуск
- В командной строке выполните C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat amd64
- Беги qmake и наслаждайся
Вы не можете вручную добавить MSVC в Qt Creator. Если вы хотите использовать его, убедитесь, что установлена правильная версия Visual Studio.
Я предлагаю переустановить Visual Studio, если компилятор MSVC не отображается на вкладке «Компиляторы».
Compile instructions (Windows — MSVC with Qt Creator)
This page is instructions for how to use the MSVC compiler inside the Qt Creator IDE. This is useful to take advantage of Qt-specific features, like visual editing of UI files in Qt Creator’s Design mode.
Getting the MSVC compiler
With Visual Studio
If you don’t mind having multiple IDEs, the easiet way to get what you need to to follow the Prerequisites section of the guide for Visual Studio and then return here when done.
Without Visual Studio
Microsoft makes their build tools available separately to the Visual Studio IDE, so if you are using Qt Creator as your IDE then in theory it should be possible to compile MuseScore without also installing Visual Studio. Unfortunately this doesn’t seem to be working at the moment, so the best thing to do is to follow the instructructions above to install with Visual Studio.
If you really want to try without Visual Studio (e.g. if short on disk space) then you can try installing just the C++ build tools. This has worked in the past, but fails with linker errors when last tried (November 2020). It’s possible this could be fixed by using the right combination of include statements in MuseScore’s header files, or by choosing the right combination of options in Microsoft’s build tools installation wizard.
To install only the C++ build tools:
- Visit this page and scroll down to All Downloads.
- Expand the Tools for Visual Studio section.
- Download Build Tools for Visual Studio.
Run the installer you downloaded, and when you get the the Workloads screen, ensure the C++ build tools option is checked. That’s the only thing you need.
You can optionally look under the Individual components tab, where you should see the following items checked:
- Under Compilers, build tools and runtimes
- C++ [year] Redistributable Update
- C++ CMake Tools for Windows
- MSVC v[version] — VS [year] — C++ x64/86 build tools (v[version])
- Testing tools core features — Build Tools
- C++ Build Tools core features
- Windows 10 SDK ([version])
- Windows Universal C Runtime
It’s possible that you don’t need all of those components, but installing them does no harm (assuming you have enough space on your drive).
Getting the CDB debugger
The Windows 10 SDK offered with the Build Tools installer does not include debugging tools by default. To get the CDB debugger for Windows, you need to modify the SDK installation to include it.
- In the Start menu, search for Add or remove programs and open it.
- Find Windows Software Development Kit in the list of installed programs.
- Click on it and select Modify. An installation dialog pop up.
Select Change and click Next. You should see this screen:
Select the Debugging Tools for Windows option and click Change.
Getting the Qt libraries and Qt Creator
If you already have Qt installed then you can simply run the Maintenance Tool that came with it (the tool is in C:\Qt or wherever you installed Qt). If you don’t have Qt already installed, you need to download the Qt Online Installer for Windows and run that instead.
Ensure the following components are checked within the Maintenance Tool / Online Installer:
- Under the latest Qt 5.12 (currently Qt 5.12.9), the master branch meanwhile ( 484f8dc, 09Oct2020) even requires Qt 5.15 (currently Qt 5.15.1) and a C++17 capable toolchain, which comes as part of MSVC 2017/2019 and the MinGW for Qt 5.12 and later anyway).
- Select the prebuilt libraries for your MSVC compiler version (e.g. MSVC 2017 64-bit, MSVC 2019 64-bit for Qt 5.15)
- The MSVC year does not have to match the version you installed earlier (though ideally it should)
- The MSVC architecture must match the version you installed earlier
- 32 bit Windows: you must install the 32 bit libraries
- 64 bit Windows: you can choose either the 32 or 64 bit libraries, or both!
- If in doubt, install only the 64 bit libraries. That is enough to compile MuseScore for your own machine. The 32 bit libraries are only useful if you want to compile for 32 bit computers.
If you want to be able to debug within Qt Creator (recommended), also check:
- Under Developer and Designer Tools
- Qt Creator (cannot be deselected)
- Qt Creator CDB Debugger Support
Click Next to install these components.
Getting the other dependencies
Download dependencies.7z and extract the contents into the base directory. (This will create a new dependencies folder in that base directory.)
Also install Jack.
Compiling on the command line
It’s a good idea to make sure you can compile from the command line before you try to set up an IDE.
The following batch script has the commands need to set up the build environment and compile MuseScore. Modify the paths as neccesary for your machine, then save the file as msvc_build.bat inside your MuseScore code repostory.
REM Add Qt to PATH
SET «PATH=C:\Qt\5.12.9\msvc2017_64\bin;%PATH%»REM Set up build environment (next line optional, but uncomment it if compiler is not found)
REM CALL «C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvars64.bat»REM Tell MSVC to use all processor cores
SET «CFLAGS= /MP%NUMBER_OF_PROCESSORS%»
SET «CXXFLAGS= /MP%NUMBER_OF_PROCESSORS%»REM Create build directory
IF not exist «my_build_dir\» MKDIR «my_build_dir»
CD my_build_dirREM Configure, build and install MuseScore
cmake .. -DCMAKE_BUILD_TYPE=RELWITHDEBINFO -DCMAKE_INSTALL_PREFIX=my_install_dir
cmake —build . -j %NUMBER_OF_PROCESSORS%
cmake —build . —target installECHO «Executable location: my_build_dir\my_install_dir\bin\MuseScore4.exe»
Add the script’s filename to .git/info/exclude to prevent it from being checked-in to the repository.
To run the script:
- In the Start menu, search for CMD.
- Type cd (change directory) followed by a space and the path to your MuseScore code repository
- e.g. cd C:\Users\[username]\MuseScore
- Press Enter to run the cd command
- Type the name of the file msvc_build.bat and press Enter to run it.
- If you need to run it again, simply press the Up arrow key to get the previous command back and press Enter to run it again.
The following shortcuts make command prompt much easier to use:
- Up and Down arrow keys: cycle through commands previously typed in this session
- Tab key: autocomplete a command, filename, or path (i.e. type a few characters then press Tab)
- Ctrl+C: stop a command that is taking a long time to complete
- Ctrl+Shift+C copy highlighted text (must be enabled in CMD Properties, see below)
- Ctrl+Shift+V paste text (must be enabled in CMD Properties, see below)
Clicking the CMD icon in the top left corner of the window brings up a menu with useful options, including Edit and Properties. You might want to go into Properties and enable «Use Ctrl+Shift+C/V as Copy/Paste». These are the standard copy and paste shortcuts available in most Command Prompt / Terminal applications on Windows and Linux.
Note: there are two other primary build modes, debug and release . Debug is not currently supported for MSVC due to linking errors.
Working in Qt Creator
IDEs are convenient for experienced users, but they introduce another layer of complexity. If something goes wrong then you might not know whether the issue is with the IDE or the compiler.
Editing files
To retain control over the compile process, you could choose to ignore Qt Creator’s IDE features and just use it as a text editor for MuseScore’s .cpp, .h and .ui files. Simply keep your Command Prompt open in a separate window, and press Up and Enter every time you want to recompile.
To set up a basic project where Qt Creator is only used as a text editor:
- Within Qt Creator, go to File → New File or Project
- Select «Import Project» and «Import Existing Project»
- Enter project details:
- Name: «MuseScore» (or «MuseScore_Windows» if you share this folder with another OS)
- Location: «
- Filter the list by filetype:
- Add *.ui to the list of types shown
- Add * to the list of types hidden (hides everything else)
- Now apply the filter.
- Choose which files to include:
- Uncheck all directories except libmscore , mscore and mtest
- Click «Next».
- You may prefer to use Git from the command line (recommended) or an external GUI tool.
Debugging
You can debug inside Qt Creator even if the program wasn’t built in Qt Creator.
To set this up within your Qt Creator project:
- Click Projects in the left panel
- Find your Build Kit (e.g. Desktop Qt 5.15.1 MSVC2019 64-bit) on the left (you may only have one).
- Click the Build project option.
- In the CMake section, change the CMAKE_INSTALL_PREFIX option to the directory where you would like your compiled binary to be installed. (eg, C:\mscore-win64install). Click Apply Configuration Changes to commit your change.
- Under the Build steps, expand the Details menu. Check lrelease and uncheck all.
- Under Build Steps click Add Build Step/CMake Build. Under the Targets, check install and uncheck all. (Sometimes the checkbox list will be blank initially. If you click on another project and then click back this will often refresh the list)
- Click on the Run project option. In the Run Settings window, under Run click Add. and then Custom Executable. You can now enter the custom path for your executable here. For example:
- Executable: C:\mscore-win64install\bin\MuseScore4.exe
- Arguments: -F (if you always want to debug in MuseScore’s initial state)
- Working directory: %
Now when you want to debug, go to the Debug menu > Start debugging > Start debugging without deployment.
If you try to debug and see the message «Unable to create a debugging engine», make sure that you installed the Debugging Tools inside the Windows SDK and installed CDB Debugger Support in Qt Creator as explained earlier. If it still doesn’t work then go to the Projects tab in the left panel, click «Manage Kits» and make sure the correct debugger is selected for you chosen kit.
Custom compilation
To avoid having to open CMD, you can tell Qt Creator to run your mybuild.bat script for you every time you press a compile button with Qt Creator itself. This gives you the best of both worlds: you get the convenience of an IDE but still have the flexibility and reliability of a separate build script.
To get Qt Creator to use your build script:
- Click Projects in the left panel
- Find your Build Kit (e.g. Desktop Qt 5.12.9 MSVC2017 64-bit) on the left (you may only have one).
- Click the Build button to edit the build configuration and do the following:
- Delete any existing Build Steps, then click Add Build Step > Custom Process Step
- Command: mybuild.bat
- Working directory: %
- Delete any existing Clean Steps, then click Add Clean Step > Custom Process Step
- Command: msvc_build.bat
- Arguments: clean
- Working directory: %
Now when you want to build, simply press the big green triangle with the bug in the bottom left of the screen. When you want to delete the build files and start again, go to the Build menu and choose «Clean Project».
Full project set-up
MuseScore uses the CMake build system. The «proper» way to set up a CMake project in Qt Creator is as follows:
- Go to File > Open File or Project
- Choose MuseScore’s top-level CMakeLists.txt file
Qt Creator will spend a few minutes «configuring» the project, but once that’s done everything is set up all ready for you to click «build». There’s no need to go messing around with build and debug configurations, as Qt Creator does this automatically. At least, that’s the theory.
In practice, the automatic method is vulnerable to changes in the CMake files, and it tends to break fairly often without reason. This forces you to run the configuration again, which takes a few minutes in Qt Creator (and other IDEs) but only takes a couple of seconds on the command line.
Ultimately, the most reliable way to compile is to copy whatever is done inside the build scripts used for MuseScore’s CI tests. Build scripts will always use a command line method rather than an IDE.
Как установить компилятор msvc
Configure VS Code for Microsoft C++
In this tutorial, you configure Visual Studio Code to use the Microsoft Visual C++ compiler and debugger on Windows.
After configuring VS Code, you will compile and debug a simple Hello World program in VS Code. This tutorial does not teach you details about the Microsoft C++ toolset or the C++ language. For those subjects, there are many good resources available on the Web.
If you have any problems, feel free to file an issue for this tutorial in the VS Code documentation repository.
To successfully complete this tutorial, you must do the following:
Install the C/C++ extension for VS Code. You can install the C/C++ extension by searching for ‘c++’ in the Extensions view ( kb(workbench.view.extensions) ).

Install the Microsoft Visual C++ (MSVC) compiler toolset.
If you have a recent version of Visual Studio, open the Visual Studio Installer from the Windows Start menu and verify that the C++ workload is checked. If it’s not installed, then check the box and select the Modify button in the installer.
You can also install the Desktop development with C++ workload without a full Visual Studio IDE installation. From the Visual Studio Downloads page, scroll down until you see Tools for Visual Studio 2022 under the All Downloads section and select the download for Build Tools for Visual Studio 2022.

This will launch the Visual Studio Installer, which will bring up a dialog showing the available Visual Studio Build Tools workloads. Check the Desktop development with C++ workload and select Install.

Note : You can use the C++ toolset from Visual Studio Build Tools along with Visual Studio Code to compile, build, and verify any C++ codebase as long as you also have a valid Visual Studio license (either Community, Pro, or Enterprise) that you are actively using to develop that C++ codebase.
Check your Microsoft Visual C++ installation
To use MSVC from a command line or VS Code, you must run from a Developer Command Prompt for Visual Studio. An ordinary shell such as PowerShell, Bash, or the Windows command prompt does not have the necessary path environment variables set.
To open the Developer Command Prompt for VS, start typing ‘developer’ in the Windows Start menu, and you should see it appear in the list of suggestions. The exact name depends on which version of Visual Studio or the Visual Studio Build Tools you have installed. Select the item to open the prompt.

You can test that you have the C++ compiler, cl.exe , installed correctly by typing ‘cl’ and you should see a copyright message with the version and basic usage description.

If the Developer Command Prompt is using the BuildTools location as the starting directory (you wouldn’t want to put projects there), navigate to your user folder ( C:\users\
\ ) before you start creating new projects. Note : If for some reason you can’t run VS Code from a Developer Command Prompt, you can find a workaround for building C++ projects with VS Code in Run VS Code outside a Developer Command Prompt.
Create Hello World
From the Developer Command Prompt, create an empty folder called «projects» where you can store all your VS Code projects, then create a subfolder called «helloworld», navigate into it, and open VS Code ( code ) in that folder ( . ) by entering the following commands:
The «code .» command opens VS Code in the current working folder, which becomes your «workspace». As you go through the tutorial, you will see three files created in a .vscode folder in the workspace:
- tasks.json (build instructions)
- launch.json (debugger settings)
- c_cpp_properties.json (compiler path and IntelliSense settings)
Add a source code file
In the File Explorer title bar, select the New File button and name the file helloworld.cpp .
Add hello world source code
Now paste in this source code:
Now press kb(workbench.action.files.save) to save the file. Notice how the file you just added appears in the File Explorer view ( kb(workbench.view.explorer) ) in the side bar of VS Code:

You can also enable Auto Save to automatically save your file changes, by checking Auto Save in the main File menu.
The Activity Bar on the far left lets you open different views such as Search, Source Control, and Run. You’ll look at the Run view later in this tutorial. You can find out more about the other views in the VS Code User Interface documentation.
Note : When you save or open a C++ file, you may see a notification from the C/C++ extension about the availability of an Insiders version, which lets you test new features and fixes. You can ignore this notification by selecting the X (Clear Notification).
In your new helloworld.cpp file, hover over vector or string to see type information. After the declaration of the msg variable, start typing msg. as you would when calling a member function. You should immediately see a completion list that shows all the member functions, and a window that shows the type information for the msg object:

You can press the kbstyle(Tab) key to insert the selected member; then, when you add the opening parenthesis, you will see information about any arguments that the function requires.
Remember, the C++ extension uses the C++ compiler you have installed on your machine to build your program. Make sure you have a C++ compiler installed before attempting to run and debug helloworld.cpp in VS Code.
Open helloworld.cpp so that it is the active file.
Press the play button in the top right corner of the editor.
Choose C/C++: cl.exe build and debug active file from the list of detected compilers on your system.
You’ll only be asked to choose a compiler the first time you run helloworld.cpp . This compiler will be set as the «default» compiler in tasks.json file.
After the build succeeds, your program’s output will appear in the integrated Terminal.
If you get an error trying to build and debug with cl.exe, make sure you have started VS Code from the Developer Command Prompt for Visual Studio using the code . shortcut.
The first time you run your program, the C++ extension creates tasks.json , which you’ll find in your project’s .vscode folder. tasks.json stores build configurations.
Your new tasks.json file should look similar to the JSON below:
Note : You can learn more about tasks.json variables in the variables reference.
The command setting specifies the program to run; in this case that is «cl.exe». The args array specifies the command-line arguments that will be passed to cl.exe. These arguments must be specified in the order expected by the compiler.
This task tells the C++ compiler to take the active file ( $
), compile it, and create an executable file ( /Fe: switch) in the current directory ( $ ) with the same name as the active file but with the .exe extension ( $ .exe ), resulting in helloworld.exe for our example. The label value is what you will see in the tasks list; you can name this whatever you like.
The detail value is what you will as the description of the task in the tasks list. It’s highly recommended to rename this value to differentiate it from similar tasks.
The problemMatcher value selects the output parser to use for finding errors and warnings in the compiler output. For cl.exe, you’ll get the best results if you use the $msCompile problem matcher.
From now on, the play button will read from tasks.json to figure out how to build and run your program. You can define multiple build tasks in tasks.json , and whichever task is marked as the default will be used by the play button. In case you need to change the default compiler, you can run Tasks: Configure default build task. Alternatively you can modify the tasks.json file and remove the default by replacing this segment:
You can modify your tasks.json to build multiple C++ files by using an argument like «$
/*.cpp» instead of $ .This will build all .cpp files in your current folder. You can also modify the output filename by replacing «$ \\$ .exe» with a hard-coded filename (for example «$ \\myProgram.exe» ). - Go back to helloworld.cpp so that it is the active file.
- Set a breakpoint by clicking on the editor margin or using F9 on the current line.
- From the drop-down next to the play button, select Debug C/C++ File.
- Choose C/C++: cl.exe build and debug active file from the list of detected compilers on your system (you’ll only be asked to choose a compiler the first time you run/debug helloworld.cpp ).
The play button has two modes: Run C/C++ File and Debug C/C++ File. It will default to the last-used mode. If you see the debug icon in the play button, you can just click the play button to debug, instead of selecting the drop-down menu item.
If you get an error trying to build and debug with cl.exe, make sure you have started VS Code from the Developer Command Prompt for Visual Studio using the code . shortcut.
Explore the debugger
Before you start stepping through the code, let’s take a moment to notice several changes in the user interface:
The Integrated Terminal appears at the bottom of the source code editor. In the Debug Output tab, you see output that indicates the debugger is up and running.
The editor highlights the line where you set a breakpoint before starting the debugger:
The Run view on the left shows debugging information. You’ll see an example later in the tutorial.
At the top of the code editor, a debugging control panel appears. You can move this around the screen by grabbing the dots on the left side.

Step through the code
Now you’re ready to start stepping through the code.
Click or press the Step over icon in the debugging control panel.
This will advance program execution to the first line of the for loop, and skip over all the internal function calls within the vector and string classes that are invoked when the msg variable is created and initialized. Notice the change in the Variables window on the left.

In this case, the errors are expected because, although the variable names for the loop are now visible to the debugger, the statement has not executed yet, so there is nothing to read at this point. The contents of msg are visible, however, because that statement has completed.
Press Step over again to advance to the next statement in this program (skipping over all the internal code that is executed to initialize the loop). Now, the Variables window shows information about the loop variables.
Press Step over again to execute the cout statement. (Note that as of the March 2019 release, the C++ extension does not print any output to the Debug Console until the loop exits.)
If you like, you can keep pressing Step over until all the words in the vector have been printed to the console. But if you are curious, try pressing the Step Into button to step through source code in the C++ standard library!

To return to your own code, one way is to keep pressing Step over. Another way is to set a breakpoint in your code by switching to the helloworld.cpp tab in the code editor, putting the insertion point somewhere on the cout statement inside the loop, and pressing kb(editor.debug.action.toggleBreakpoint) . A red dot appears in the gutter on the left to indicate that a breakpoint has been set on this line.

Then press kb(workbench.action.debug.start) to start execution from the current line in the standard library header. Execution will break on cout . If you like, you can press kb(editor.debug.action.toggleBreakpoint) again to toggle off the breakpoint.
Sometimes you might want to keep track of the value of a variable as your program executes. You can do this by setting a watch on the variable.
Place the insertion point inside the loop. In the Watch window, select the plus sign and in the text box, type word , which is the name of the loop variable. Now view the Watch window as you step through the loop.

Add another watch by adding this statement before the loop: int i = 0; . Then, inside the loop, add this statement: ++i; . Now add a watch for i as you did in the previous step.
To quickly view the value of any variable while execution is paused on a breakpoint, you can hover over it with the mouse pointer.

Customize debugging with launch.json
When you debug with the play button or kb(workbench.action.debug.start) , the C++ extension creates a dynamic debug configuration on the fly.
There are cases where you’d want to customize your debug configuration, such as specifying arguments to pass to the program at runtime. You can define custom debug configurations in a launch.json file.
To create launch.json , choose Add Debug Configuration from the play button drop-down menu.
You’ll then see a dropdown for various predefined debugging configurations. Choose C/C++: cl.exe build and debug active file.
VS Code creates a launch.json file, which looks something like this:
In the JSON above, program specifies the program you want to debug. Here it is set to the active file folder ( $
) and active filename with the .exe extension ( $ .exe ), which if helloworld.cpp is the active file will be helloworld.exe . The args property is an array of arguments to pass to the program at runtime. By default, the C++ extension won’t add any breakpoints to your source code and the stopAtEntry value is set to false .
Change the stopAtEntry value to true to cause the debugger to stop on the main method when you start debugging.
From now on, the play button and kb(workbench.action.debug.start) will read from your launch.json file when launching your program for debugging.
If you want more control over the C/C++ extension, you can create a c_cpp_properties.json file, which will allow you to change settings such as the path to the compiler, include paths, C++ standard (default is C++17), and more.
You can view the C/C++ configuration UI by running the command C/C++: Edit Configurations (UI) from the Command Palette ( kb(workbench.action.showCommands) ).

This opens the C/C++ Configurations page. When you make changes here, VS Code writes them to a file called c_cpp_properties.json in the .vscode folder.

Visual Studio Code places these settings in .vscode\c_cpp_properties.json . If you open that file directly, it should look something like this:
You only need to add to the Include path array setting if your program includes header files that are not in your workspace or in the standard library path.
The compilerPath setting is an important setting in your configuration. The extension uses it to infer the path to the C++ standard library header files. When the extension knows where to find those files, it can provide useful features like smart completions and Go to Definition navigation.
The C/C++ extension attempts to populate compilerPath with the default compiler location based on what it finds on your system. The extension looks in several common compiler locations.
The compilerPath search order is:
- First check for the Microsoft Visual C++ compilerOpe
- Then look for g++ on Windows Subsystem for Linux (WSL)
- Then g++ for Mingw-w64.
If you have g++ or WSL installed, you might need to change compilerPath to match the preferred compiler for your project. For Microsoft C++, the path should look something like this, depending on which specific version you have installed: «C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe».
Reusing your C++ configuration
VS Code is now configured to use the Microsoft C++ compiler. The configuration applies to the current workspace. To reuse the configuration, just copy the JSON files to a .vscode folder in a new project folder (workspace) and change the names of the source file(s) and executable as needed.
Run VS Code outside the Developer Command Prompt
In certain circumstances, it isn’t possible to run VS Code from Developer Command Prompt for Visual Studio (for example, in Remote Development through SSH scenarios). In that case, you can automate initialization of Developer Command Prompt for Visual Studio during the build using the following tasks.json configuration:
Note : The path to VsDevCmd.bat might be different depending on the Visual Studio version or installation path. You can find the path to VsDevCmd.bat by opening a Command Prompt and running dir «\VsDevCmd*» /s .
The term ‘cl.exe’ is not recognized
If you see the error «The term ‘cl.exe’ is not recognized as the name of a cmdlet, function, script file, or operable program.», this usually means you are running VS Code outside of a Developer Command Prompt for Visual Studio and VS Code doesn’t know the path to the cl.exe compiler.
VS Code must either be started from the Developer Command Prompt for Visual Studio, or the task must be configured to run outside a Developer Command Prompt.
- Delete any existing Build Steps, then click Add Build Step > Custom Process Step
- Select the prebuilt libraries for your MSVC compiler version (e.g. MSVC 2017 64-bit, MSVC 2019 64-bit for Qt 5.15)