There are several similar questions here, but in case they are outdated, still let me ask.
I did
Needs["CCompilerDriver`"]
and then
CreateExecutable[
StringJoin["int main(){\n", " printf(\"Hello world.\\n\");\n",
"}\n"], "hiworld",
"Compiler" ->
CCompilerDriver`VisualStudioCompiler`VisualStudioCompiler,
"CompilerInstallation" ->
"c:\\Program Files\\Microsoft Visual Studio\\2022\\Preview",
"CompilerName" -> Automatic, "ShellOutputFunction" -> Print]
The output is this:
During evaluation of In[2]:=
C:\Users\me\AppData\Roaming\Mathematica\SystemFiles\LibraryResources\Windows-x86-64\Working-asusi-3132-17180-1>call "c:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Auxiliary\Build\vcvarsall.bat" amd64
**********************************************************************
** Visual Studio 2022 Developer Command Prompt v17.12.0-pre.1.0
** Copyright (c) 2022 Microsoft Corporation
**********************************************************************
The system cannot find the file specified.
[vcvarsall.bat] Environment initialized for: 'x64'
Microsoft (R) C/C++ Optimizing Compiler Version 19.42.34226.3 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
hiworld.c
Microsoft (R) Incremental Linker Version 14.42.34226.3
Copyright (C) Microsoft Corporation. All rights reserved.
/out:hiworld.exe
user32.lib
kernel32.lib
gdi32.lib
"/LIBPATH:C:\Program Files\Wolfram Research\Mathematica\13.3\SystemFiles\Links\MathLink\DeveloperKit\Windows-x86-64\CompilerAdditions"
"/LIBPATH:C:\Program Files\Wolfram Research\Mathematica\13.3\SystemFiles\Libraries\Windows-x86-64"
/out:C:\Users\me\AppData\Roaming\Mathematica\SystemFiles\LibraryResources\Windows-x86-64\Working-asusi-3132-17180-1\hiworld.exe
hiworld.obj
LINK : fatal error LNK1181: cannot open input file 'user32.lib'
During evaluation of In[2]:= CreateExecutable::cmperr: Compile error: LINK : fatal error LNK1181: cannot open input file 'user32.lib'
Out[2]= $Failed
Indeed I checked that I don't have anywhere on my system files user32.lib, kernel32.lib or gdi32.lib, neither do I have user64.lib, kernel64.lib, gdi64.lib or user.lib, kernel.lib or gdi.lib.
What's wrong and how to fix it?