gpt4 book ai didi

windows-7 - 在 Windows 上运行 CMake

转载 作者:行者123 更新时间:2023-12-03 01:26:06 26 4
gpt4 key购买 nike

我目前正在尝试让 CMake 在我的 Windows 7(64 位)系统上运行。我要编译TagLib以便稍后与我正在开发的 Qt 应用程序一起使用。我想用 MinGW 编译它(而不是 this other question 中的 Visual C++)。

我下载安装程序 (cmake-2.8.3-win32-x86.exe) 并安装它(我还选择将 CMake 添加到我的路径中)。然后,我转到 CMakeLists.txt 文件所在的目录并运行 cmake .。然后它给了我这个巨大的错误。

C:\Users\Joel\Downloads\taglib-1.6.3>cmake .
CMake Warning at CMakeLists.txt:1 (project):
To use the NMake generator, cmake must be run from a shell that can use the
compiler cl from the command line. This environment does not contain
INCLUDE, LIB, or LIBPATH, and these must be set for the cl compiler to
work.


-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Warning at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/Platform/Windows-cl.cmake:
28 (ENABLE_LANGUAGE):
To use the NMake generator, cmake must be run from a shell that can use the
compiler cl from the command line. This environment does not contain
INCLUDE, LIB, or LIBPATH, and these must be set for the cl compiler to
work.
Call Stack (most recent call first):
C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeCInformation.cmake:60 (INCLUDE)
CMakeLists.txt:1 (project)


CMake Error: your RC compiler: "CMAKE_RC_COMPILER-NOTFOUND" was not found. Please set CMAKE_RC_COM
PILER to a valid compiler path or name.
-- Check for CL compiler version
-- Check for CL compiler version - failed
-- Check if this is a free VC compiler
-- Check if this is a free VC compiler - yes
-- Using FREE VC TOOLS, NO DEBUG available
-- Check for working C compiler: cl
CMake Warning at CMakeLists.txt:2 (PROJECT):
To use the NMake generator, cmake must be run from a shell that can use the
compiler cl from the command line. This environment does not contain
INCLUDE, LIB, or LIBPATH, and these must be set for the cl compiler to
work.


CMake Warning at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/Platform/Windows-cl.cmake:
28 (ENABLE_LANGUAGE):
To use the NMake generator, cmake must be run from a shell that can use the
compiler cl from the command line. This environment does not contain
INCLUDE, LIB, or LIBPATH, and these must be set for the cl compiler to
work.
Call Stack (most recent call first):
C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeCInformation.cmake:60 (INCLUDE)
CMakeLists.txt:2 (PROJECT)


CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeRCInformation.cmake:22
(GET_FILENAME_COMPONENT):
get_filename_component called with incorrect number of arguments
Call Stack (most recent call first):
C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/Platform/Windows-cl.cmake:28 (ENABLE_LANG
UAGE)
C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeCInformation.cmake:60 (INCLUDE)
CMakeLists.txt:2 (PROJECT)


CMake Error: CMAKE_RC_COMPILER not set, after EnableLanguage
CMake Error: your C compiler: "cl" was not found. Please set CMAKE_C_COMPILER to a valid compiler
path or name.
CMake Error: Internal CMake error, TryCompile configure of cmake failed
-- Check for working C compiler: cl -- broken
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:52
(MESSAGE):
The C compiler "cl" is not able to compile a simple test program.

It fails with the following output:





CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:1 (project)


CMake Error: your C compiler: "cl" was not found. Please set CMAKE_C_COMPILER to a valid compiler
path or name.
CMake Error: your CXX compiler: "cl" was not found. Please set CMAKE_CXX_COMPILER to a valid compi
ler path or name.
-- Configuring incomplete, errors occurred!

C:\Users\Joel\Downloads\taglib-1.6.3>

考虑到它宣传自己是一个跨平台品牌,我对它如此失败感到有点惊讶。

我尝试将 INCLUDE、LIB 和 LIBPATH(Windows 环境变量)全部设置到我的 MinGW 二进制文件目录 (C:\MinGW\bin),但它仍然给我同样的错误。我还尝试将 CMAKE_C_COMPILER 和 CMAKE_CXX_COMPILER 设置为 g++ 的位置 (C:\MinGW\bin\g++)。

有人知道这是怎么回事吗?

解决方案:

根据 tibur 的建议,我运行 cmake GUI 来创建 make 文件。然后,我进入 taglib 目录并运行 mingw32-make.exe 来执行实际的构建。

最佳答案

Windows 的默认生成器似乎设置为 NMAKE。尝试使用:

cmake -G "MinGW Makefiles"

或者使用 GUI,并在提示输入生成器时选择 MinGW Makefiles。不要忘记清理您尝试运行 CMake 的目录,或删除 GUI 中的缓存。否则,它将使用 NMAKE 重试。

关于windows-7 - 在 Windows 上运行 CMake,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4101456/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com