



- #include
-
- int main()
- {
- std::cout << "\nhello world\n" << std::endl;
- return 0;
- }
参考CMake官网



在CMakeLists.txt文件中添加:
- cmake_minimum_required(VERSION 3.10)
-
- # set the project name
- project(Tutorial)
-
- # add the executable
- add_executable(Tutorial tutorial.cxx)


Unable to determine what CMake generator to use. Please install or configure a preferred generator, or update settings.json, your Kit configuration or PATH variable.


然后在弹出来的文件保存管理窗口中直接点“保存”即可。

- {
- "folders": [
- {
- "path": "."
- }
- ],
- "settings": {
- "files.associations": {
- "*.ejs": "html",
- "iostream": "cpp"
- },
- "cmake.generator": "MinGW Makefiles"
-
- }
- }
改成这个样子即可(添加了划红线的语句,旨在告诉CMake你要用的generator姓甚名谁)

"cmake.generator": "MinGW Makefiles"

- [proc] Executing command: C:\Program_Files_AI\gcc\gcc_1221\ucrt64\bin\gcc.exe -v
- [main] Configuring folder: Ctest01
- [proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_C_COMPILER:FILEPATH=C:\Program_Files_AI\gcc\gcc_1221\ucrt64\bin\gcc.exe -DCMAKE_CXX_COMPILER:FILEPATH=C:\Program_Files_AI\gcc\gcc_1221\ucrt64\bin\g++.exe -Sd:/Workspaces_C++/Ctest01 -Bd:/Workspaces_C++/Ctest01/build -G "MinGW Makefiles"
- [cmake] Not searching for unused variables given on the command line.
- [cmake] -- The C compiler identification is GNU 12.2.1
- [cmake] -- The CXX compiler identification is GNU 12.2.1
- [cmake] -- Detecting C compiler ABI info
- [cmake] -- Detecting C compiler ABI info - done
- [cmake] -- Check for working C compiler: C:/Program_Files_AI/gcc/gcc_1221/ucrt64/bin/gcc.exe - skipped
- [cmake] -- Detecting C compile features
- [cmake] -- Detecting C compile features - done
- [cmake] -- Detecting CXX compiler ABI info
- [cmake] -- Detecting CXX compiler ABI info - done
- [cmake] -- Check for working CXX compiler: C:/Program_Files_AI/gcc/gcc_1221/ucrt64/bin/g++.exe - skipped
- [cmake] -- Detecting CXX compile features
- [cmake] -- Detecting CXX compile features - done
- [cmake] -- Configuring done
- [cmake] -- Generating done
- [cmake] -- Build files have been written to: D:/Workspaces_C++/Ctest01/build


VScode的Unable to determine what CMake generator to use问题处理_LYZ832的博客-CSDN博客
[C++入门] 超简单 VSCode C++开发环境搭建_哔哩哔哩_bilibili