【问题标题】:CMake Errors - Using ConanCMake 错误 - 使用柯南
【发布时间】:2023-03-11 22:05:01
【问题描述】:

我只是想不通为什么我会收到这个错误,有人介意给我一些帮助吗?

我已将 Cmake 添加到环境变量中,但仍然出现错误。我目前是一名大学生,正在努力让 SDL 发挥作用。

我的机器是 x64,我有安装了所有 C++ 元素的 Visual Studio 2017。

这里是 CMD 错误: CMD Error

这是 GUI 错误: GUI Error

复制 - 粘贴 CMD 版本:

-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:1 (PROJECT):
  No CMAKE_C_COMPILER could be found.



CMake Error at CMakeLists.txt:1 (PROJECT):
  No CMAKE_CXX_COMPILER could be found.



-- Configuring incomplete, errors occurred!
See also "C:/Users/Chris Ross/.conan/data/zlib/1.2.8/lasote/stable/build/6cc50b139b9c3d27b3e9042d5f5372d327b3a9f7/_build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/Chris Ross/.conan/data/zlib/1.2.8/lasote/stable/build/6cc50b139b9c3d27b3e9042d5f5372d327b3a9f7/_build/CMakeFiles/CMakeError.log".
zlib/1.2.8@lasote/stable:
zlib/1.2.8@lasote/stable: ERROR: Package '6cc50b139b9c3d27b3e9042d5f5372d327b3a9f7' build failed
zlib/1.2.8@lasote/stable: WARN: Build folder C:\Users\Chris Ross\.conan\data\zlib\1.2.8\lasote\stable\build\6cc50b139b9c3d27b3e9042d5f5372d327b3a9f7
ERROR: zlib/1.2.8@lasote/stable: Error in build() method, line 60
        self.run('%s && cmake .. %s' % (cd_build, cmake.command_line))
        ConanException: Error 1 while executing cd _build && cmake .. -G "Visual Studio 15 2017 Win64" -DCONAN_LINK_RUNTIME="/MD" -DCONAN_EXPORTED="1" -DCONAN_COMPILER="Visual Studio" -DCONAN_COMPILER_VERSION="15" -DCONAN_CXX_FLAGS="/MP4" -DCONAN_C_FLAGS="/MP4" -Wno-dev
INFO: Conan job finished.
INFO: Starting cmake
CMake Error: Error: generator : Visual Studio 14 2015 Win64
Does not match the generator used previously: Visual Studio 15 2017 Win64
Either remove the CMakeCache.txt file and CMakeFiles directory or choose a different binary directory.
INFO: CMake job finished.

复制 - 粘贴 GUI 版本:

    CMAKE_CONFIGURATION_TYPES              Debug;Release;MinSizeRel;RelWithDebInfo
    CMAKE_INSTALL_PREFIX                   C:/Program Files (x86)/lab1

Configuring incomplete, errors occurred!
See also "C:/Users/Chris Ross/Desktop/lab2template/bin/CMakeFiles/CMakeOutput.log".
See also "C:/Users/Chris Ross/Desktop/lab2template/bin/CMakeFiles/CMakeError.log".

我的conanfile.txt:

[requires]
SDL2/2.0.5@dotfloat/stable
SDL2_image/2.0.1@lasote/stable
SDL2_mixer/2.0.1@a_teammate/testing
SDL2_ttf/2.0.14@hilborn/stable

[options]
SDL2:shared=True
SDL2_image:shared=False
SDL2_mixer:shared=True
SDL2_ttf:shared=False

[generators]
cmake

[imports]
bin, *.dll -> ./bin # Copies all dll files from packages bin folder to my "bin" folder
lib, *.dylib* -> ./bin # Cop

使用这个 .bat 文件:

@echo off

:start
echo INFO: I am running from '%cd%'
if exist src goto changetobin

:conan
echo INFO: Starting conan
conan install --build missing
echo INFO: Conan job finished.
goto cmake

:cmake
echo INFO: Starting cmake
cmake .. -G "Visual Studio 14 2015 Win64"
echo INFO: CMake job finished.
goto end

:changetobin
echo ERROR: I'm in the wrong directory.. moving into bin
cd bin
echo INFO: Retrying..
goto start

:end
if exist bin goto quit
cd ..
goto quit

:quit
echo.
echo.
echo INFO: Conan and CMake ran successfully. Open up your solution file (listed below) to open your project.
echo.
dir /b *.sln

(我也尝试过手动构建(conan install --build 缺失))

【问题讨论】:

  • 复制粘贴错误,而不是发布它们的屏幕截图。
  • 错误提示CMake找不到Visual Studio安装的MSVC编译器。您能否确认您安装了 VS 2015,并选择 C++ 编译器作为其安装组件的一部分?
  • 我目前使用的是 VS 2017(已安装 C++,我可以制作项目),我的朋友建议我卸载 VS 2015 来解决问题,但它没有用:/“Visual Studio 15 2017”有在 CMake gui 中被选中。
  • 有什么原因你没有为 zlib 使用这个柯南包吗? bintray.com/conan-community/conan/zlib%3Aconan/1.2.8%3Astable
  • @ChristopherRoss 您说您使用的是 Visual Studio 2017,那么为什么要为 VS2015 生成解决方案? cmake .. -G "Visual Studio 14 2015 Win64"

标签: c++ cmake sdl conan


【解决方案1】:

“我的机器是 x64,我有安装了所有 C++ 元素的 Visual Studio 2017。”

您正在为错误版本的 Visual Studio 生成解决方案。

cmake .. -G "Visual Studio 14 2015 Win64"

将批处理脚本中的那一行更改为:

cmake .. -G "Visual Studio 15 2017 Win64"

那么您必须删除所有生成的文件(CMakeCache.txt', 'CMakeFiles dir 等)并重试。还请仔细检查您的柯南配置文件设置是否与您使用的编译器匹配。

【讨论】:

  • 我做到了,仍然没有希望。完全相同的错误。我已经尝试了所有这些,每一个。
  • 我建议您尝试卸载 CMake,删除其所有文件(验证 Program Files\CMake 是否 100% 为空并消失),然后将其重新安装到它将重新检测您的编译器的位置,然后然后只使用您已安装的 Visual Studio 版本的生成器。我以前经历过这种痛苦,并通过重新安装获得了成功。
猜你喜欢
  • 2021-12-15
  • 1970-01-01
  • 1970-01-01
  • 2021-11-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-08-13
  • 1970-01-01
相关资源
最近更新 更多