无法使用Visual Studio 2015在Windows 10上构建LLVM

时间:2016-12-07 12:42:26

标签: c++ cmake llvm cmake-gui

我正在尝试使用Visual Studio在Windows 10上安装LLVM,使用指南http://llvm.org/docs/GettingStartedVS.html,但我收到了错误:

以下是我在CMake GUI中的观点,我在其中指导它使用C ++编译器C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe

我已经为构建创建了一个名为llvm的新目录,因为我无法在源目录中构建。

我做错了什么?

enter image description here

配置过程显示以下输出:

The C compiler identification is unknown
The CXX compiler identification is unknown
The ASM compiler identification is MSVC
Found assembler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe
CMake Error at CMakeLists.txt:48 (project):
  No CMAKE_C_COMPILER could be found.



Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe
CMake Error: Generator: execution of make failed. Make command was: "MSBuild.exe" "cmTC_c88f4.vcxproj" "/p:Configuration=Debug" "/p:VisualStudioVersion=15.0"
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe -- broken
CMake Error at C:/Program Files/CMake/share/cmake-3.7/Modules/CMakeTestCXXCompiler.cmake:44 (message):
  The C++ compiler "C:/Program Files (x86)/Microsoft Visual Studio
  14.0/VC/bin/cl.exe" is not able to compile a simple test program.

  It fails with the following output:

   Change Dir: C:/dev/llvm/CMakeFiles/CMakeTmp



  Run Build Command:"MSBuild.exe" "cmTC_c88f4.vcxproj"
  "/p:Configuration=Debug" "/p:VisualStudioVersion=15.0"



  Generator: execution of make failed.  Make command was: "MSBuild.exe"
  "cmTC_c88f4.vcxproj" "/p:Configuration=Debug" "/p:VisualStudioVersion=15.0"





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


Configuring incomplete, errors occurred!
See also "C:/dev/llvm/CMakeFiles/CMakeOutput.log".
See also "C:/dev/llvm/CMakeFiles/CMakeError.log".

1 个答案:

答案 0 :(得分:0)

我正在使用相同的设置(Windows 32位除外),我选择的LLVM版本是4.0.0。我按照教程使用clang进行设置。

我为整个过程做了笔记。 从源代码构建LLVM 4.0.0的说明:

  • 在任何合适的位置创建名为LLVM的文件夹。
  • cd LLVM
  • svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
  • cd llvm \ tools
  • svn co http://llvm.org/svn/llvm-project/cfe/trunk clang
  • cd ....#回到你开始的地方
  • mkdir build
  • cd build
  • cmake -G" Visual Studio 14" .. \ llvm ##取决于您使用的VS版本,我使用VS 2015 - > VISUAL STUDIO 14.0
  • 如果成功,您将在构建目录中找到可在Visual Studio中打开的LLVM.sln文件,一旦打开,您可以浏览解决方案资源管理器并右键单击ALL_BUILD项目 - >建立。

注意:

  • 我正在使用Visual Studio 2015(更新3)
  • 我使用的是Windows 10 32位系统
  • 可以通过将路径附加到可在Program Files中的Visual Studio 14.0文件夹中找到的文件来修复头文件依赖项。
  • 我的环境变量供参考:

    ** INCLUDE = C:\ Program Files \ Microsoft Visual Studio 14.0 \ VC \ INCLUDE; C:\ Program Files \ Microsoft Visual Studio 14.0 \ VC \ ATLMFC \ INCLUDE; C:\ Program Files \ Windows Kits \ 10 \ include \ 10.0.10240.0 \ ucrt; C:\ Program Files \ Windows Kits \ NETFXSDK \ 4.6.1 \ include \ um; C:\ Program Files \ Windows Kits \ 8.1 \ include \ shared; C:\ Program Files \ Windows Kits \ 8.1 \ include \ um; C:\ Program Files \ Windows Kits \ 8.1 \ include \ winrt;

    ** LIBPATH = C:\ Windows \ Microsoft.NET \ Framework \ v4.0.30319; C:\ Program Files \ Microsoft Visual Studio 14.0 \ VC \ LIB; C:\ Program Files \ Microsoft Visual Studio 14.0 \ VC \ ATLMFC \ LIB; C:\ Program Files \ Windows Kits \ 8.1 \ References \ CommonConfiguration \ Neutral; \ Microsoft.VCLibs \ 14.0 \ References \ CommonConfiguration \ neutral;

  • 如果在开发人员命令提示符下无法识别llvm工具(如clang,llc,lli等),请设置PATH环境变量。

  • 从github下载时,您还可能会发现构建中缺少clang和clang ++等可执行文件。我从我为windows下载的预构建二进制文件中复制了这些文件,这些文件可以在LLVM版本页面找到。

希望这有帮助!