问题描述
我试图用Cmake编译Visual Studio解决方案编译最新版本的aseprite和cmake保持给我:
找不到CMAKE_C_COMPILER。
未找到CMAKE_CXX_COMPILER。
我已经下载了gcc并且正在使用visual studio 2015。
我正在关注本教程/
我一直在搜索
CMake错误在...(项目):
没有找到CMAKE_C_COMPILER。
- 配置不完整,发生错误!
另请参见... / CMakeFiles / CMakeOutput.log。
另请参见... / CMakeFiles / CMakeError.log。
或
CMake错误:您的CXX编译器:找不到CMAKE_CXX_COMPILER-NOTFOUND。
请将CMAKE_CXX_COMPILER设置为有效的编译器路径或名称。
...
- 配置不完整,发生错误!
只是意味着CMake无法找到您的C / CXX编译器来编译一个简单的测试程序检测您的构建环境时,CMake尝试的第一件事)。
找到您的问题的步骤取决于您要生成的构建环境。以下教程是这里的StackOverflow和一些我自己的经验与CMake在MS Windows 7/8上的答案集合。
前提条件
- / IDE,它能够编译任何其他程序(直接没有CMake)
- 您有最新的
- 您拥有您希望CMake生成您的构建环境的驱动器的访问权限
-
目录(因为CMake缓存的东西从最后一次尝试)例如作为源代码树的子目录
Windows cmd.exe
> rmdir / s / q VS2015
> mkdir VS2015
> cd VS2015
Bash shell
$ rm -rf MSYS
$ mkdir MSYS
$ cd MSYS
并确保您的命令shell指向新创建的二进制输出目录。
CMake能找到并运行任何/你的默认编译器?不提供生成器运行
> cmake ..
- 构建于:Visual Studio 14 2015
...
完美如果它正确地确定了发电机使用 - 像这里 Visual Studio 14 2015
是真的失败了吗?
在上一个生成输出目录中,查看 CMakeFiles\CMakeError.log
您或尝试直接打开/编译在 CMakeFiles \ [Version] \CompilerIdC
| CompilerIdCXX
CMake找不到Visual Studio
-
尝试选择正确的
> cmake --help
> cmake -GVisual Studio 14 2015..
-
首先设置VS环境变量(路径可能不同)
> c:\Program Files(x86)\ Microsoft Visual Studio 14.0 \VC\vcvarsall.bat
> cmake ..
或使用VS2015的
开发人员命令提示符
所有程序
/Visual Studio 2015
/> Visual Studio Tools
(感谢提示)
背景:CMake支持所有Visual Studio版本和风格(Express,Community,Professional,Premium,团队,企业,终极,...)。要确定编译器的位置,它使用搜索注册表(例如在 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\ [版本]; InstallDir
)的组合,
CMake无法找到GCC(MinGW / MSys)
-
您启动MSys
bash
与msys.bat
,并尝试直接调用gcc
$ gcc
gcc.exe:fatal错误:没有输入文件
编译终止。
这里找到了
gcc
因此,以下内容应该可以工作:
$ cmake -GMSYS Makefiles..
- CXX编译器标识是GNU 4.8.1
...
$ make
如果没有找到GCC调用
export PATH = ...
添加您的编译器路径(请参阅
注意:当使用MinGW Makefile生成器时,您必须使用随MinGW分发的
mingw32-make
程序 -
仍然无法运作吗?这很奇怪。请确保编译器在那里并且具有可执行权限(参见上面的前提条件)。
否则,CMake的最后手段是不要尝试任何编译器搜索本身并直接通过
设置CMake的内部变量。
$ cmake -DCMAKE_C_COMPILER = / c / MinGW / bin / gcc.exe -DCMAKE_CXX_COMPILER = c / MinGW / bin / g ++。exe ..
有关详细信息,请参阅和
或者,这些变量也可以通过
cmake-gui.exe
。请参见
背景:与Visual Studio相同。 CMake支持各种GCC风格。它搜索环境变量(CC,CXX,...)或者只是尝试调用编译器。此外,它会检测任何前缀(当),并尝试将其添加到GNU编译器工具链的所有binutils ( ar
, ranlib
, strip
, ld
, nm
, objdump
, objcopy
)。
I'm trying make a Visual Studio solution with Cmake to compile the latest version of aseprite and the cmake keeps giving me the :
No CMAKE_C_COMPILER could be found.
No CMAKE_CXX_COMPILER could be found.
I've already downloaded gcc and i'm using visual studio 2015.
I'm following this tutorial /
https://github.com/aseprite/aseprite/blob/master/INSTALL.md
I've been searching for about 3 hours and no solution on internet fitted.
Those error messages
CMake Error at ... (project):
No CMAKE_C_COMPILER could be found.
-- Configuring incomplete, errors occurred!
See also ".../CMakeFiles/CMakeOutput.log".
See also ".../CMakeFiles/CMakeError.log".
or
CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found.
Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
...
-- Configuring incomplete, errors occurred!
just mean that CMake was unable to find your C/CXX compiler to compile a simple test program (one of the first things CMake tries while detecting your build environment).
The steps to find your problem are dependent on the build environment you want to generate. The following tutorials are a collection of answers here on StackOverflow and some of my own experiences with CMake on MS Windows 7/8.
Preconditions
- You have installed the compiler/IDE and it was able to once compile any other program (directly without CMake)
- You have the latest CMake version
- You have access rights on the drive you want CMake to generate your build environment
You have a clean build directory (because CMake does cache things from the last try) e.g. as sub-directory of your source tree
Windows cmd.exe
> rmdir /s /q VS2015 > mkdir VS2015 > cd VS2015
Bash shell
$ rm -rf MSYS $ mkdir MSYS $ cd MSYS
and make sure your command shell points to your newly created binary output directory.
General things you can/should try
Is CMake able find and run with any/your default compiler? Run without giving a generator
> cmake .. -- Building for: Visual Studio 14 2015 ...
Perfect if it correctly determined the generator to use - like here
Visual Studio 14 2015
What was it that actually failed?
In the previous build output directory look at
CMakeFiles\CMakeError.log
for any error message that make sense to you or try to open/compile the test project generated atCMakeFiles\[Version]\CompilerIdC
|CompilerIdCXX
directly from the command line (as found in the error log).
CMake can't find Visual Studio
Try to select the correct generator version
> cmake --help > cmake -G "Visual Studio 14 2015" ..
If that doesn't help try to set the VS environment variables first (the path could vary)
> "c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" > cmake ..
or use the
Developer Command Prompt for VS2015
short-cut in your Windows Start Menu underAll Programs
/Visual Studio 2015
/Visual Studio Tools
(thanks at @Antwane for the hint)
Background: CMake does support all Visual Studio releases and flavors (Express, Community, Professional, Premium, Test, Team, Enterprise, Ultimate, ...). To determine the location of the compiler it uses a combination of searching the registry (e.g. at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\[Version];InstallDir
), system environment variables and - if none of the others did come up with something - plainly try to call the compiler.
CMake can't find GCC (MinGW/MSys)
You start the MSys
bash
shell withmsys.bat
and just try to directly callgcc
$ gcc gcc.exe: fatal error: no input files compilation terminated.
Here it did find
gcc
and is complaining that I didn't gave it any parameters to work with.So the following should work:
$ cmake -G "MSYS Makefiles" .. -- The CXX compiler identification is GNU 4.8.1 ... $ make
If GCC was not found call
export PATH=...
to add your compilers path (see How to set PATH environment variable in CMake script?) and try again.If it's still not working, try to set the CXX compiler path directly by exporting it (path may vary)
$ export CC=/c/MinGW/bin/gcc.exe $ export CXX=/c/MinGW/bin/g++.exe $ cmake -G "MinGW Makefiles" .. -- The CXX compiler identification is GNU 4.8.1 ... $ mingw32-make
For more details see how to specify new gcc path for cmake
Note: When using the "MinGW Makefiles" generator you have to use the
mingw32-make
program distributed with MinGWStill not working? That's weird. Please make sure that the compiler is there and it has executable rights (see also preconditions chapter above).
Otherwise the last resort of CMake is to not try any compiler search itself and set CMake's internal variables directly by
$ cmake -DCMAKE_C_COMPILER=/c/MinGW/bin/gcc.exe -DCMAKE_CXX_COMPILER=/c/MinGW/bin/g++.exe ..
For more details see Cmake doesn't honour -D CMAKE_CXX_COMPILER=g++ and Cmake error setting compiler
Alternatively those variables can also be set via
cmake-gui.exe
on Windows. See Cmake cannot find compiler
Background: Much the same as with Visual Studio. CMake supports all sorts of GCC flavors. It searches the environment variables (CC, CXX, ...) or simply tries to call the compiler. In addition it will detect any prefixes (when cross-compiling) and tries to add it to all binutils of the GNU compiler toolchain (ar
, ranlib
, strip
, ld
, nm
, objdump
, objcopy
).
这篇关于CMake错误在CMakeLists.txt:30(项目):没有CMAKE_C_COMPILER可以找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!