MSVC 16.8.0 Preview 3.2 cannot find standard module interface files

1.3k views Asked by At
import std.core;

int main()
{
    std::cout << "Hello World!\n";
}

If I compile this code from the command line, using this cl /c /O2 /D NDEBUG /D _CONSOLE /D _UNICODE /D UNICODE /EHsc /MD /std:c++latest /Gd /TP /experimental:module /ifcSearchDir "C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.28.29304\ifc\x64\Release" ConsoleApplication1.cpp it compiles and links fine.

If I compile the same code using the IDE and the same options, the Output window shows this result.

1>cl /c /O2 /D NDEBUG /D _CONSOLE /D _UNICODE /D UNICODE /EHsc /MD /std:c++latest /Gd /TP /experimental:module /ifcSearchDir "C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.28.29304\ifc\x64\Release" ConsoleApplication1.cpp
1>ConsoleApplication1.cpp
1>ConsoleApplication1.cpp(1): fatal error C1011: cannot locate standard module interface. Did you install the library part of the C++ modules feature in VS setup?
1>Done building project "ConsoleApplication1.vcxproj" -- FAILED.

Can anybody enlighten me to what is going on here? What am I forgetting?

2

There are 2 answers

0
jcjustesen On

I found a workaround, if I open a Developer Command Prompt or run vcvarsall.bat, I can then start Visual Studio from the command line using "devenv" and then modules will work. I suspect the environment is not setup correctly when Visual Studio is started normally.

0
David Constantine On

I was breaking my head for a while why it is not compiling in my new 2022 Visual Studio.

Beside the obvious /experimental:module and /std:c++latest

You actually have to install those modules separately!!!

enter image description here