首先,无论是Windows仍是Linux版本CoreCLR的编译,都是在Windows10上进行的。python
在Windows上作编译怎么能少得了Visual Studio,因为Visual Studio 2017刚刚发布,因此选用Visual Studio 2017版本做为编译工具。linux
.NET Desktop Developmentgit
Desktop Development with C++github
还有一个比较重要的问题,就是使用VS2017的话,还须要注册一个Visual Studio 2015的组件,须要运行以下命令:regsvr32.exe %VSINSTALLDIR%\Common7\IDE\msdia120.dll ,由于须要VS2017的环境变量,固然这也须要在Developer Command Prompt for VS2017 中运行。
还有最重要一点Visual Studio Express 2017不支持编译CoreCLR。shell
要编译CoreCLR须要CMake 3.7.2及以上版本,记得加环境变量Path。ubuntu
官方给出的所需版本为 python 2.7.9,可是python 3也能很好的支持,记得加环境变量Path。windows
这个是必需的嘛。bash
Windows 10 自带4.0,因此Win10就没问题。curl
不须要解释吧,没有去官网下载吧。ide
其实这部分有个小插曲就是,若是使用Visual Studio 2017编译的话会有一个小BUG,文档上给的例子是直接运行命令:
./build.cmd
可是会获得以下结果:
Microsoft.CSharp.Core.targets(106,11): error MSB4064: The "OverrideToolHost" parameter is not supported by the "Csc" task. Verify the parameter exists on the task, and it is a settable public instance property.
BUG的地址以下:https://github.com/dotnet/coreclr/issues/10056
运行下面三条命令其中之一就能够解决这个问题了,解决方法以下:
build x64 skiptests -- /p:CSharpCoreTargetsPath=Roslyn\Microsoft.CSharp.Core.targets build x64 checked skiptests -- /p:CSharpCoreTargetsPath=Roslyn\Microsoft.CSharp.Core.targets build x64 release skiptests -- /p:CSharpCoreTargetsPath=Roslyn\Microsoft.CSharp.Core.targets
推荐第一条命令,生成DEBUG版本。
这里使用Windows 10编译Linux版本是由于Win10里带有Bash,bash是一个基于Ubuntu 14.04的Windows子系统,能够“完美”模拟Linux环境,固然下面所讲的过程也彻底能够在真正的Ubuntu上编译。
官方推荐的是ubuntu 14.04,固然也能够是别的Linux版本,本文也是使用这个版本进行的。
要安装lldb-3.6须要在Ubuntu上添加安装源:
echo "deb http://llvm.org/apt/trusty/ llvm-toolchain-trusty-3.6 main" | sudo tee /etc/apt/sources.list.d/llvm.list wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key | sudo apt-key add - sudo apt-get update
若是系统里没有git的话,须要本身安装下。接着要安装组件,命令以下:
sudo apt-get install cmake llvm-3.5 clang-3.5 lldb-3.6 lldb-3.6-dev libunwind8 libunwind8-dev gettext libicu-dev liblttng-ust-dev libcurl4-openssl-dev libssl-dev uuid-dev
./build.sh
Linux上的编译相对比较简单,可是若是是DEBUG的话,Windows版本要很容易实现。编译两个版本的过程当中会通过漫长的等待(最好找个代理)。
下篇文章我会讲下在Windows环境下的调试,还有我作的一些小的修改过程。