MS software is so ubiquitous on Windows that even when you don’t remember installing their stuff, one day you wake up and find out that you already did. I accidentally double right clicked on a std::cout
and ended up activating a VSCode feature that takes you to the definition of the symbol you just selected. (I had no idea you could do that btw, that’s pretty neat)
I saw this:
At first I thought this was some VSCode C++ extension related thing but then I looked at the paths of the headers files on the right and I realized something was wrong.
I was surprised, and spent some a while trying to figure out how this could happen on a fresh install. It turns out, it got installed at the same date as Nodejs. I am not sure if Node still uses VS build tools for node-gyp
. There’s a big chance that I might have installed this myself outside of the Nodejs installer, by issuing an npm i -g windows-build-tools
command.
In any case, now that I actually had an MSVC compiler I thought why not have some fun with it.
I tried compiling a Hello World program with it directly but it failed because it lacked an include path for iostream.
Apparently you have to go to “Microsoft Visual Studio\2017\BuildTools\Common7\Tools” and activate vsdevcmd.bat for it to work.
Interestingly, Win32 programs that compile straightforward with g++ don’t do the same with cl.exe.
I found out that you actually need to tell the compiler to link the correct static library .lib file to your program with a #pragma comment declaration below your header include statement.
#include <windows.h> #pragma comment(lib,"user32.lib") #include <shlobj.h> #pragma comment(lib,"shell32.lib")
I’m eager to experiment with cl.exe
and msbuild
but I’ll stick with MinGW for now.