-
Hello, I would like to be able to compile a simple program in C/C++ with Visual Studio Code and mingw-w64. So, I have installed Mingw-w64 (following the doc on https://www.msys2.org/)
So, I create my working folder, add helloworld.cpp file with example on the doc and that's where the problems start. My c_cpp_properties.json file:
So, as I saw in the FAQ, I try to modify my "includePath" in c_cpp_properties.json by adding include folder (D:/Dvpt/msys64/ucrt64/include/**)
As you can see, squiggles under Standard Library types disappeared but I have another error Strangely I haven't found an answer to my problem on the web and very few people seem to have this problem. I have spend hours trying to correct the problem but without success.
And to finish, here is my C/C++ Log diagnostics
|
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 17 replies
-
Can you please do the following 3 things?
With the debug logging enabled, it should hopefully tell us why getting the proper include path from your MinGW installation is failing. Copy and paste that log here and we can see what the next steps are. |
Beta Was this translation helpful? Give feedback.
-
Hi @bobbrow, Thanks for your answer. Debug Log``` loggingLevel: Debug LSP: (received) cpptools/initialize (id: 1) LSP: (invoked) cpptools/initialize (id: 1) cpptools version (TypeScript): 1.22.11 cpptools version (native): 1.22.11.0 Autocomplete is enabled. Error squiggles are enabled if all header dependencies are resolved. Hover is enabled. IntelliSense Engine = default. LSP: Sending response (id: 1) LSP: (received) cpptools/queryCompilerDefaults (id: 2) LSP: (invoked) cpptools/queryCompilerDefaults (id: 2) Querying compiler for default C++ language standard using command line: D:\Dvpt\msys64\ucrt64\bin\gcc.exe -x c++ -E -dM nul Querying compiler for default C++ language standard using command line: D:\Dvpt\msys64\ucrt64\bin\gcc.exe -x c++ -E -dM /dev/null Detected language standard version: c++98 Querying compiler's default target using command line: "D:\Dvpt\msys64\ucrt64\bin\gcc.exe" -dumpmachine Compiler returned default target value: x86_64-w64-mingw32 Compiler info database not connected - skipping load. Compiler query command line: D:\Dvpt\msys64\ucrt64\bin\gcc.exe -std=c17 -m64 -Wp,-v -E -dM -x c nul Attempting to get defaults from C compiler in "compilerPath" property: 'D:\Dvpt\msys64\ucrt64\bin\gcc.exe' Compiler info database not connected - skipping load. Compiler query command line: D:\Dvpt\msys64\ucrt64\bin\gcc.exe -std=c++98 -m64 -Wp,-v -E -dM -x c++ nul Failed to query compiler. Falling back to 32-bit intelliSenseMode. Compiler query command line: D:\Dvpt\msys64\ucrt64\bin\gcc.exe -std=c++98 -m32 -Wp,-v -E -dM -x c++ nul Failed to query compiler. Falling back to no bitness. Compiler query command line: D:\Dvpt\msys64\ucrt64\bin\gcc.exe -std=c++98 -Wp,-v -E -dM -x c++ nul Attempting to get defaults from C++ compiler in "compilerPath" property: 'D:\Dvpt\msys64\ucrt64\bin\gcc.exe' Compiler info database not connected - skipping load. Unable to configure for compiler cl.exe. Attempting to get defaults from compiler found on the machine: 'D:\Dvpt\msys64\ucrt64\bin\gcc.exe' Compiler info database not connected - skipping load. Compiler query command line: D:\Dvpt\msys64\ucrt64\bin\gcc.exe -std=c++98 -m64 -Wp,-v -E -dM -x c++ nul Failed to query compiler. Falling back to 32-bit intelliSenseMode. Compiler query command line: D:\Dvpt\msys64\ucrt64\bin\gcc.exe -std=c++98 -m32 -Wp,-v -E -dM -x c++ nul Failed to query compiler. Falling back to no bitness. Compiler query command line: D:\Dvpt\msys64\ucrt64\bin\gcc.exe -std=c++98 -Wp,-v -E -dM -x c++ nul No suitable compiler found. Please set the "compilerPath" in c_cpp_properties.json. LSP: Sending response (id: 2) LSP: (received) cpptools/queryCompilerDefaults (id: 3) LSP: (invoked) cpptools/queryCompilerDefaults (id: 3) LSP: (received) cpptools/didChangeCppProperties (id: 4) Compiler info database not connected - skipping load. Compiler query command line: D:\Dvpt\msys64\ucrt64\bin\gcc.exe -std=c++98 -m64 -Wp,-v -E -dM -x c++ nul LSP: (received) cpptools/didChangeSettings LSP: (received - deferred) cpptools/didChangeVisibleTextEditors LSP: (received - deferred) cpptools/didChangeVisibleTextEditors Failed to query compiler. Falling back to 32-bit intelliSenseMode. Compiler query command line: D:\Dvpt\msys64\ucrt64\bin\gcc.exe -std=c++98 -m32 -Wp,-v -E -dM -x c++ nul Failed to query compiler. Falling back to no bitness. Compiler query command line: D:\Dvpt\msys64\ucrt64\bin\gcc.exe -std=c++98 -Wp,-v -E -dM -x c++ nul Attempting to get defaults from C++ compiler in "compilerPath" property: 'D:\Dvpt\msys64\ucrt64\bin\gcc.exe' Compiler info database not connected - skipping load. Unable to configure for compiler cl.exe. Attempting to get defaults from compiler found on the machine: 'D:\Dvpt\msys64\ucrt64\bin\gcc.exe' Compiler info database not connected - skipping load. Compiler query command line: D:\Dvpt\msys64\ucrt64\bin\gcc.exe -std=c++98 -m64 -Wp,-v -E -dM -x c++ nul Failed to query compiler. Falling back to 32-bit intelliSenseMode. Compiler query command line: D:\Dvpt\msys64\ucrt64\bin\gcc.exe -std=c++98 -m32 -Wp,-v -E -dM -x c++ nul Failed to query compiler. Falling back to no bitness. Compiler query command line: D:\Dvpt\msys64\ucrt64\bin\gcc.exe -std=c++98 -Wp,-v -E -dM -x c++ nul No suitable compiler found. Please set the "compilerPath" in c_cpp_properties.json. LSP: Sending response (id: 3) LSP: (invoked) cpptools/didChangeCppProperties (id: 4) Unable to access browse database. (get_structure_version) Code browsing service initialized Compiler query command line: D:\Dvpt\msys64\ucrt64\bin\gcc.exe -std=c++98 -m64 -Wp,-v -E -dM -x c++ nul Failed to query compiler. Falling back to 32-bit intelliSenseMode. Compiler query command line: D:\Dvpt\msys64\ucrt64\bin\gcc.exe -std=c++98 -m32 -Wp,-v -E -dM -x c++ nul Failed to query compiler. Falling back to no bitness. Compiler query command line: D:\Dvpt\msys64\ucrt64\bin\gcc.exe -std=c++98 -Wp,-v -E -dM -x c++ nul Attempting to get defaults from C++ compiler in "compilerPath" property: 'D:\Dvpt\msys64\ucrt64\bin\gcc.exe' Unable to configure for compiler cl.exe. Attempting to get defaults from compiler found on the machine: 'D:\Dvpt\msys64\ucrt64\bin\gcc.exe' Compiler query command line: D:\Dvpt\msys64\ucrt64\bin\gcc.exe -std=c++98 -m64 -Wp,-v -E -dM -x c++ nul Failed to query compiler. Falling back to 32-bit intelliSenseMode. Compiler query command line: D:\Dvpt\msys64\ucrt64\bin\gcc.exe -std=c++98 -m32 -Wp,-v -E -dM -x c++ nul Failed to query compiler. Falling back to no bitness. Compiler query command line: D:\Dvpt\msys64\ucrt64\bin\gcc.exe -std=c++98 -Wp,-v -E -dM -x c++ nul No suitable compiler found. Please set the "compilerPath" in c_cpp_properties.json. Folder: D:\DVPT\MSYS64\UCRT64\INCLUDE\ will be indexed Folder: D:\DVPT\MSYS64\UCRT64\LIB\GCC\X86_64-W64-MINGW32\14.2.0\INCLUDE\ will be indexed Folder: D:\DVPT\MSYS64\UCRT64\LIB\GCC\X86_64-W64-MINGW32\14.2.0\INCLUDE-FIXED\ will be indexed LSP: (queued) cpptools/didChangeVisibleTextEditors LSP: (queued) cpptools/didChangeVisibleTextEditors LSP: Sending response (id: 4) LSP: (invoked) cpptools/didChangeSettings Discovering files... Autocomplete is enabled. Error squiggles are enabled if all header dependencies are resolved. Hover is enabled. IntelliSense Engine = default. Enhanced Colorization is enabled. LSP: (invoked) cpptools/didChangeVisibleTextEditors Processing folder (recursive): D:\DVPT\MSYS64\UCRT64\LIB\GCC\X86_64-W64-MINGW32\14.2.0\INCLUDE-FIXED\ Processing folder (recursive): D:\DVPT\MSYS64\UCRT64\INCLUDE\ Processing folder (recursive): D:\DVPT\MSYS64\UCRT64\LIB\GCC\X86_64-W64-MINGW32\14.2.0\INCLUDE\ Discovering files: 3646 file(s) processed 0 file(s) removed from database Done discovering files. Populating include completion cache. Parsing remaining files... Parsing: 0 files(s) processed Done parsing remaining files. LSP: (received) cpptools/didChangeVisibleTextEditors LSP: (invoked) cpptools/didChangeVisibleTextEditors LSP: (received) textDocument/didOpen: file:///d%3A/Project/helloworld.cpp LSP: (invoked) textDocument/didOpen: file:///d%3A/Project/helloworld.cpp tag parsing file: D:\Project\helloworld.cpp LSP: (received) cpptools/didChangeVisibleTextEditors LSP: (invoked) cpptools/didChangeVisibleTextEditors Intellisense update pending for: file:///d%3A/Project/helloworld.cpp LSP: (received) cpptools/didChangeVisibleTextEditors LSP: (invoked) cpptools/didChangeVisibleTextEditors LSP: (received) cpptools/didChangeActiveEditor: file:///d%3A/Project/helloworld.cpp LSP: (invoked) cpptools/didChangeActiveEditor: file:///d%3A/Project/helloworld.cpp LSP: (received) cpptools/getCodeActions: file:///d%3A/Project/helloworld.cpp (id: 5) LSP: (invoked) cpptools/getCodeActions: file:///d%3A/Project/helloworld.cpp (id: 5) LSP: Sending response (id: 5) LSP: (received) cpptools/getDocumentSymbols: file:///d%3A/Project/helloworld.cpp (id: 6) LSP: (invoked) cpptools/getDocumentSymbols: file:///d%3A/Project/helloworld.cpp (id: 6) IntelliSense update scheduled and TU acquisition started for: file:///d%3A/Project/helloworld.cpp Populating file name cache... Done populating filename cache. Elapsed time: 16 ms Resolving recursive includes... Done resolving recursive includes. sending compilation args for D:\Project\helloworld.cpp include: D:\PROJECT define: _DEBUG define: UNICODE define: _UNICODE stdver: ms_c++17 intelliSenseMode: windows-msvc-x64 LSP: Sending response (id: 6) Error squiggles will be disabled in: file:///d%3A/Project/helloworld.cpp Update IntelliSense time (sec): 0.15 LSP: (received) cpptools/getFoldingRanges: file:///d%3A/Project/helloworld.cpp (id: 7) LSP: (invoked) cpptools/getFoldingRanges: file:///d%3A/Project/helloworld.cpp (id: 7) LSP: Sending response (id: 7) LSP: (received) cpptools/getFoldingRanges: file:///d%3A/Project/helloworld.cpp (id: 8) LSP: (invoked) cpptools/getFoldingRanges: file:///d%3A/Project/helloworld.cpp (id: 8) LSP: Sending response (id: 8) LSP: (received) cpptools/getCodeActions: file:///d%3A/Project/helloworld.cpp (id: 9) LSP: (invoked) cpptools/getCodeActions: file:///d%3A/Project/helloworld.cpp (id: 9) LSP: Sending response (id: 9) LSP: (received) cpptools/getFoldingRanges: file:///d%3A/Project/helloworld.cpp (id: 10) LSP: (invoked) cpptools/getFoldingRanges: file:///d%3A/Project/helloworld.cpp (id: 10) LSP: Sending response (id: 10) Database safe to open. ```
|
Beta Was this translation helpful? Give feedback.
-
It appears to query for C just fine, but appears to be failing to query C++ information. Also strange is that it is asking for C++98 instead of C++17 which is what your original log showed you were requesting. Can you try running the following commands in a terminal window (not VS Code's terminal) and let me know what happens?
EDIT: removed the |
Beta Was this translation helpful? Give feedback.
-
I have read the following doc: https://code.visualstudio.com/docs/languages/cpp And I have download the compiler from the ling inside the doc: As you can see, the link points to msys2-x86_64-20240113.exe (the one I have installed) But on the first page, there is another "old" link: You are right, I will uninstall MinGW from my previous install and try the "old" one. |
Beta Was this translation helpful? Give feedback.
-
I have installed the "previous" version and now when I execute the following command line I have this: gcc.exe -std=c++98 -Wp,-v -E -dM -x c++ nul
gcc.exe -std=c++17 -Wp,-v -E -dM -x c++ nul
And now, in the outpout debug window I have this
|
Beta Was this translation helpful? Give feedback.
-
With the "previous" install form the link below it works very well:
I can compile a simple HelloWorld at least 👍 |
Beta Was this translation helpful? Give feedback.
Hi @bobbrow,
I have used Dependency and I have found the origin of the problem with the dll.
I simply put on the top the D:\Dvpt\msys64\ucrt64\bin folder in Local Environment variables.
Now I can execute the following command without problem:
gcc.exe -std=c++98 -Wp,-v -E -dM -x c++ nul
gcc.exe -std=c++17 -Wp,-v -E -dM -x c++ nul
After that, I had again a small problem with the extension:
And it was due to the following entry in System Environment Variables:
I renamed it for a test and all works perfectly now!
No more error messages either like:
[1/15/2025, 8:35:17 PM] Unable to resolve configuration with compilerPath "D:\Dvpt\msys64\ucrt64\bin\g++.exe". Using "D:\Dvpt\msys64\ucrt64\b…