Некоторая информация о моей системе
Я использую 64-разрядную версию Windows и скачал mingw из winlibs и добавил его в «PATH», а cmake (версия 3.31.3) скачал с официального сайта в виде zip-файла, также добавил его в «PATH», и vcpkg с в руководстве добавлено добавление "VCPKG_ROOT" и пути к нему в качестве переменной ENVIRONMENT и еще раз в "PATH".
каталог helloworld:
- vcpkg.json:
"dependencies": [
"fmt"
]
}
- Cmakelists.txt
project(HelloWorld)
find_package(fmt CONFIG REQUIRED)
add_executable(HelloWorld helloworld.cpp)
target_link_libraries(HelloWorld PRIVATE fmt::fmt)
- vcpkg-configuration.json
"default-registry": {
"kind": "git",
"baseline": "80d54ff62d528339c626a6fbc3489a7f25956ade",
"repository": "https://github.com/microsoft/vcpkg"
},
"registries": [
{
"kind": "artifact",
"location": "https://github.com/microsoft/vcpkg-ce-c ... s/main.zip",
"name": "microsoft"
}
]
}
- helloworld.cpp
int main()
{
fmt::print("Hello World!\n");
return 0;
}
- CMakePresets.json
"version": 2,
"configurePresets": [
{
"name": "vcpkg",
"generator": "MinGW Makefiles",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
}
}
]
}
- CMakeUserPresets.json
"version": 2,
"configurePresets": [
{
"name": "default",
"inherits": "vcpkg",
"environment": {
"VCPKG_ROOT": "C:/vcpkg"
}
}
]
}
Проблема
После помещения всего этого в каталог helloworld. Я использовал команду «cmake --preset=default» внутри каталога helloworld, и она вывела следующую ошибку:
Preset CMake variables:
CMAKE_TOOLCHAIN_FILE="C:/vcpkg/scripts/buildsystems/vcpkg.cmake"
Preset environment variables:
VCPKG_ROOT="C:/vcpkg"
-- Running vcpkg install
Fetching registry information from https://github.com/microsoft/vcpkg (HEAD)...
error: in triplet x64-windows: Unable to find a valid Visual Studio instance
Could not locate a complete Visual Studio instance
-- Running vcpkg install - failed
CMake Error at C:/vcpkg/scripts/buildsystems/vcpkg.cmake:904 (message):
vcpkg install failed. See logs for more information:
C:/helloworld/build/vcpkg-manifest-install.log
Call Stack (most recent call first):
C:/cmake/share/cmake-3.31/Modules/CMakeDetermineSystem.cmake:146 (include)
CMakeLists.txt:3 (project)
CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
и внутри «C:/helloworld/build/vcpkg-manifest-install.log» это:
Fetching registry information from https://github.com/microsoft/vcpkg (HEAD)...
error: in triplet x64-windows: Unable to find a valid Visual Studio instance
Could not locate a complete Visual Studio instance
Я должен упомянуть, что cmake может распознавать «MinGW Makefiles», но без vcpkg.
Поэтому я не думаю, что это проблема в моем «PATH». ", или любую переменную среды в моей системе.
Это "version_info.txt" для используемой версии winlib:
winlibs personal build version gcc-14.2.0-llvm-19.1.1-mingw-w64ucrt-12.0.0-r2
This is the winlibs Intel/AMD 64-bit standalone build of:
- GCC 14.2.0
- GDB 15.2
- LLVM/Clang/LLD/LLDB 19.1.1
- MinGW-w64 12.0.0 (linked with ucrt)
- GNU Binutils 2.43.1
- GNU Make 4.4.1
- PExports 0.47
- dos2unix 7.5.2
- Yasm 1.3.0
- NASM 2.16.01
- JWasm 2.12pre
- ccache 4.10.2
- CMake 3.30.4
- ninja 1.12.1
- Doxygen 1.12.0
- Universal Ctags 6.1.0
- Cppcheck 2.15.0
Thread model: posix
Runtime library: UCRT (Windows 10 or higher, or when [Update for Universal C Runtime](https://support.microsoft.com/en-us/top ... 7930f3560c) is installed on older Windows versions, not supported on systems older than Windows 7 SP1 and Windows Server 2008 R2 SP1)
Подробнее здесь: https://stackoverflow.com/questions/793 ... sing-vcpkg