一、編譯環(huán)境
首先细办,不管是Windows還是Linux版本CoreCLR的編譯碍讯,都是在Windows10上進(jìn)行的属瓣。
二、CoreCLR for Windows
在Windows上做編譯怎么能少得了Visual Studio,由于Visual Studio 2017剛剛發(fā)布棒仍,所以選用Visual Studio 2017版本作為編譯工具悲靴。
編譯組件
Visual Studio 2017安裝組件
.NET Desktop Development
- All Required Components
- .NET Framework 4-4.6 Development Tools
Desktop Development with C++
- All Required Components
- VC++ 2017 v141 Toolset (x86, x64)
- Windows 8.1 SDK and UCRT SDK
- VC++ 2015.3 v140 Toolset (x86, x64)
還有一個(gè)比較重要的問(wèn)題,就是使用VS2017的話莫其,還需要注冊(cè)一個(gè)Visual Studio 2015的組件癞尚,需要運(yùn)行如下命令:regsvr32.exe %VSINSTALLDIR%\Common7\IDE\msdia120.dll ,因?yàn)樾枰猇S2017的環(huán)境變量乱陡,當(dāng)然這也需要在Developer Command Prompt for VS2017 中運(yùn)行浇揩。
還有最重要一點(diǎn)Visual Studio Express 2017不支持編譯CoreCLR。
CMake
要編譯CoreCLR需要CMake 3.7.2及以上版本憨颠,記得加環(huán)境變量Path胳徽。
Python
官方給出的所需版本為 python 2.7.9,但是python 3也能很好的支持爽彤,記得加環(huán)境變量Path养盗。
Git
這個(gè)是必需的嘛。
PowerShell
Windows 10 自帶4.0淫茵,所以Win10就沒(méi)問(wèn)題爪瓜。
DotNet Core SDK
不需要解釋吧,沒(méi)有去官網(wǎng)下載吧匙瘪。
windows編譯
其實(shí)這部分有個(gè)小插曲就是铆铆,如果使用Visual Studio 2017編譯的話會(huì)有一個(gè)小BUG,文檔上給的例子是直接運(yùn)行命令:
./build.cmd
但是會(huì)得到如下結(jié)果:
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
運(yùn)行下面三條命令其中之一就可以解決這個(gè)問(wèn)題了丹喻,解決方法如下:
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版本。
三碍论、CoreCLR for Linux
這里使用Windows 10編譯Linux版本是因?yàn)閃in10里帶有Bash谅猾,bash是一個(gè)基于Ubuntu 14.04的Windows子系統(tǒng),可以“完美”模擬Linux環(huán)境鳍悠,當(dāng)然下面所講的過(guò)程也完全可以在真正的Ubuntu上編譯税娜。
系統(tǒng)
官方推薦的是ubuntu 14.04,當(dāng)然也可以是別的Linux版本藏研,本文也是使用這個(gè)版本進(jìn)行的敬矩。
系統(tǒng)組件
- 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
- git
要安裝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
如果系統(tǒng)里沒(méi)有g(shù)it的話,需要自己安裝下蠢挡。接著要安裝組件弧岳,命令如下:
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
Linux編譯
./build.sh
四、總結(jié)
Linux上的編譯相對(duì)比較簡(jiǎn)單业踏,但是如果是DEBUG的話禽炬,Windows版本要很容易實(shí)現(xiàn)。編譯兩個(gè)版本的過(guò)程中會(huì)經(jīng)過(guò)漫長(zhǎng)的等待(最好找個(gè)代理)勤家。
下篇文章我會(huì)講下在Windows環(huán)境下的調(diào)試腹尖,還有我做的一些小的修改過(guò)程。
首發(fā)博客:http://www.dotnet.ren
博客園:http://www.cnblogs.com/maxzhang1985