C编译器标识是未知的,尽管设置CC和CXX变量 [英] C compiler identification is unknown despite setting CC and CXX variables

查看:8204
本文介绍了C编译器标识是未知的,尽管设置CC和CXX变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的命令:

    cmake CC="C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\cl.exe" 
CXX="C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\cl.exe"  -G "Visual Studio 12
 Win64" -DBOOST_ROOT="c:\local\boost_1_56_0" -DBOOST_LIBRARYDIR="c:\local\boost_1_56_0\lib64-
msvc-12.0"  ..

它说:

The C compiler identification is unknown

The CXX compiler identification is unknown

EDIT :错误日志文件:

Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler:  
Build flags: 
Id flags: 

The output was:
1
Microsoft (R) Build Engine version 12.0.30723.0
[Microsoft .NET Framework, version 4.0.30319.18444]
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 21-09-2014 20:17:49.
Project "D:\foo\build\CMakeFiles\3.0.2\CompilerIdC\CompilerIdC.vcxproj" on node 1 (default targets).
PrepareForBuild:
  Creating directory "Debug\".
  Creating directory "Debug\CompilerIdC.tlog\".
InitializeBuildStatus:
  Creating "Debug\CompilerIdC.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
ClCompile:
  C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64\CL.exe /c /nologo /W0 /WX- /Od /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fo"Debug\\" /Fd"Debug\vc120.pdb" /Gd /TC /errorReport:queue CMakeCCompilerId.c
  CMakeCCompilerId.c
Link:
  C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64\link.exe /ERRORREPORT:QUEUE /OUT:".\CompilerIdC.exe" /INCREMENTAL:NO /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /PDB:".\CompilerIdC.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:".\CompilerIdC.lib" /MACHINE:X64 Debug\CMakeCCompilerId.obj
LINK : fatal error LNK1181: cannot open input file 'gdi32.lib' [D:\foo\build\CMakeFiles\3.0.2\CompilerIdC\CompilerIdC.vcxproj]
Done Building Project "D:\foo\build\CMakeFiles\3.0.2\CompilerIdC\CompilerIdC.vcxproj" (default targets) -- FAILED.

Build FAILED.

"D:\foo\build\CMakeFiles\3.0.2\CompilerIdC\CompilerIdC.vcxproj" (default target) (1) ->
(Link target) -> 
  LINK : fatal error LNK1181: cannot open input file 'gdi32.lib' [D:\foo\build\CMakeFiles\3.0.2\CompilerIdC\CompilerIdC.vcxproj]

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:00.47


Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
Compiler:  
Build flags: 
Id flags: 

The output was:
1
Microsoft (R) Build Engine version 12.0.30723.0
[Microsoft .NET Framework, version 4.0.30319.18444]
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 21-09-2014 20:17:50.
Project "D:\foo\build\CMakeFiles\3.0.2\CompilerIdCXX\CompilerIdCXX.vcxproj" on node 1 (default targets).
PrepareForBuild:
  Creating directory "Debug\".
  Creating directory "Debug\CompilerIdCXX.tlog\".
InitializeBuildStatus:
  Creating "Debug\CompilerIdCXX.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
ClCompile:
  C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64\CL.exe /c /nologo /W0 /WX- /Od /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fo"Debug\\" /Fd"Debug\vc120.pdb" /Gd /TP /errorReport:queue CMakeCXXCompilerId.cpp
  CMakeCXXCompilerId.cpp
Link:
  C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64\link.exe /ERRORREPORT:QUEUE /OUT:".\CompilerIdCXX.exe" /INCREMENTAL:NO /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /PDB:".\CompilerIdCXX.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:".\CompilerIdCXX.lib" /MACHINE:X64 Debug\CMakeCXXCompilerId.obj
LINK : fatal error LNK1181: cannot open input file 'gdi32.lib' [D:\foo\build\CMakeFiles\3.0.2\CompilerIdCXX\CompilerIdCXX.vcxproj]
Done Building Project "D:\foo\build\CMakeFiles\3.0.2\CompilerIdCXX\CompilerIdCXX.vcxproj" (default targets) -- FAILED.

Build FAILED.

"D:\foo\build\CMakeFiles\3.0.2\CompilerIdCXX\CompilerIdCXX.vcxproj" (default target) (1) ->
(Link target) -> 
  LINK : fatal error LNK1181: cannot open input file 'gdi32.lib' [D:\foo\build\CMakeFiles\3.0.2\CompilerIdCXX\CompilerIdCXX.vcxproj]

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:00.50


推荐答案

可以使用 CC CXX 变量,但是它比使用 -G (generator)参数复杂得多。例如,路径中的斜杠必须是Unix风格( / ),并且在第一次运行CMake配置后它们才会生效,除非缓存被清除。

The compiler can be selected by using the CC and CXX variables, but by it's much more complicated than using the -G (generator) parameter. For one, the slashes in the path must be Unix style (/) and they don't take effect after the first time CMake configuration is ran unless the cache is cleared.

可用的发电机选项列表包括 - help 选项

For a list of available generator options include the --help option

Boost库的路径也必须使用Unix样式斜杠( / )。许多命令将转换Windows路径,但是当在命令行中传递定义时,您将总是使用Unix风格路径。

The paths to the Boost library must also use Unix style slashes (/). Many of the commands will convert Windows paths, but when passing in definitions at the command-line you'll want to always use Unix style paths.

您的命令将更改为以下内容:

Your command would change to the following:


cmake -GVisual Studio 12 2013 Win64-DBOOST_ROOT =C:/ local / boost_1_56_0-DBOOST_LIBRARYDIR = C:/local/boost_1_56_0/lib64-msvc-12.0..

cmake -G "Visual Studio 12 2013 Win64" -DBOOST_ROOT="C:/local/boost_1_56_0" -DBOOST_LIBRARYDIR="C:/local/boost_1_56_0/lib64-msvc-12.0" ..

您还需要确保您的PATH环境变量为Visual Studio和x64正确设置。这可以很容易地通过使用以下命令打开VS2013 x64本机工具命令提示符:

You'll also want to make sure that your PATH environment variable is setup correctly for Visual Studio and x64. This can be done easily by opening a VS2013 x64 Native Tools Command Prompt using the command below:

cmd /k "%VS120CoMNTOOLS%\..\..\VC\vcvarsall.bat" amd64

此外,你应该确保你清除cmake缓存之前,你尝试。最简单的方法是删除cmake build文件夹,但您也可以使用CMake-gui清除缓存。

In addition, you should make sure you're clearing out the cmake cache before you try. The easiest way to do this is to delete your cmake build folder, but you can also use the CMake-gui to clear the cache.

这篇关于C编译器标识是未知的,尽管设置CC和CXX变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆