Configuring VS Code with MSVC and EasyX (2021)
A historical setup guide for compiling C++ with MSVC in VS Code and linking the EasyX graphics library through tasks.json.
Contents6 sections
Historical note: This guide records a Visual Studio 2019 and MSVC 14.28/14.29 setup from May 2021. Paths and EasyX installation behavior can differ in current versions, so compare them with the latest official documentation.
VS Code, MSVC, and EasyX
EasyX did not support the MinGW toolchain used by many VS Code C++ setups, so the solution was to launch VS Code inside an initialized MSVC environment and link the EasyX libraries explicitly.
1. Configure the MSVC build environment
Microsoft's official VS Code MSVC guide is the primary reference.
Install Visual Studio C++ desktop development
In Visual Studio Installer, select Desktop development with C++. This installs the MSVC compiler and Windows development tools.

Launch VS Code from a Developer Command Prompt
Open Developer Command Prompt for Visual Studio and confirm that cl.exe is available:
cl.exe
Then open the target folder from that same prompt:
code D:\testEasyx\demo
Launching VS Code this way passes the MSVC environment variables to its integrated tasks.
Compile a first MSVC program
Create easyxdemo.cpp:
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
vector<string> message {
"Hello", "C++", "World", "from", "VS Code", "and the C++ extension!"
};
for (const string &word : message) {
cout << word << ' ';
}
cout << endl;
}
Press Ctrl+F5, choose the Windows C++ environment, and then select cl.exe. VS Code creates .vscode/tasks.json; this file becomes important when EasyX is linked later.
2. Install EasyX
Download EasyX from the official site and install it for Visual Studio.
In the original Visual Studio 2019 layout, EasyX placed files under directories such as:
VC\Auxiliary\VS\lib\x64
VC\Auxiliary\VS\lib\x86
VC\Auxiliary\VS\include
The working configuration copied:
EasyXa.libandEasyXw.libinto the matching MSVClib\x64andlib\x86directories;easyx.handgraphics.hinto the active MSVCincludedirectory.
For example, the active compiler directory was similar to:
VC\Tools\MSVC\14.28.29910\
Use the actual version directory installed on your machine rather than copying this historical version literally.
3. Link EasyX from VS Code
Test that the header resolves with a small EasyX program, such as a graphical clock using graphics.h, initgraph, GetLocalTime, and line drawing. Header completion alone is not enough; the linker still needs the Windows libraries.
Change the generated task type from cppbuild to shell and add the required .lib arguments:
{
"tasks": [
{
"type": "shell",
"label": "C/C++: cl.exe build active file",
"command": "cl.exe",
"args": [
"/Zi",
"/EHsc",
"kernel32.lib",
"gdi32.lib",
"winspool.lib",
"comdlg32.lib",
"advapi32.lib",
"shell32.lib",
"ole32.lib",
"oleaut32.lib",
"uuid.lib",
"odbc32.lib",
"odbccp32.lib",
"user32.lib",
"/nologo",
"/Fe:",
"${fileDirname}\\${fileBasenameNoExtension}.exe",
"${file}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": ["$msCompile"],
"group": {
"kind": "build",
"isDefault": true
}
}
],
"version": "2.0.0"
}
Run again with Ctrl+F5. If compilation succeeds but linking fails, verify that the current cl.exe architecture, EasyX library architecture, and copied library directory all match.
Discussion / approved
Comments
No comments yet.