Updated Building and Running CoreCLR on Linux
authorMatt Ellis <matell@microsoft.com>
Wed, 4 Mar 2015 23:08:55 +0000 (15:08 -0800)
committerRichard Lander <rlander@microsoft.com>
Tue, 14 Apr 2015 21:02:19 +0000 (14:02 -0700)
Building-and-Running-CoreCLR-on-Linux.md

index 27c4761..900bee0 100644 (file)
@@ -1,14 +1,12 @@
-This guide will walk you through building CoreCLR on Linux and running Hello World.  We'll start by showing how to set up your environment from scratch.  If you're in a hurry and want to use Docker, we have some sample images at the end of this document
-
-# From Scratch
+This guide will walk you through building CoreCLR on Linux and running Hello World.  We'll start by showing how to set up your environment from scratch.
 
 Before starting, you need to set up your development machine.  We use Ubuntu 14.04 LTS as our primary environment currently, so these instructions are written assuming you are using that Distro.  Pull Requests are welcome to address other environments as long as they don't break the ability to use Ubuntu 14.04 LTS.
 
 There have been reports of issues when using other distros or versions of Ubuntu (e.g. [Issue 95](https://github.com/dotnet/coreclr/issues/95)) so if you're on another distribution, consider using docker's ```ubuntu:14.04``` image.
 
-We install the following packages to get our toolchain: ```cmake llvm-3.5 clang-3.5 lldb-3.5 libunwind8 libunwind8-dev```.  On Ubuntu 14.04 they can be installed with ```apt-get```:
+We install the following packages to get our toolchain: ```cmake llvm-3.5 clang-3.5 lldb-3.5  lldb-3.5-dev libunwind8 libunwind8-dev```.  On Ubuntu 14.04 they can be installed with ```apt-get```:
 
-```sudo apt-get install cmake llvm-3.5 clang-3.5 lldb-3.5 libunwind8 libunwind8-dev```  
+```sudo apt-get install cmake llvm-3.5 clang-3.5 lldb-3.5 lldb-3.5-dev libunwind8 libunwind8-dev```  
 
 This gives us the 3.5 version of the llvm toolchain and version 2.8.12.2 of cmake.
 
@@ -35,12 +33,6 @@ ellismg@linux:~/git/coreclr$ cp binaries/Product/linux.x64.debug/libcoreclr.so ~
 
 Today, we don't support building the managed components of the runtime on Linux yet, so you'll need to have a Windows machine with clones of both the CoreCLR and CoreFX projects.
 
-Furthmore, the coreclr project's build system does not segment output based on the target platform yet, so in order to build the managed components for Linux, you'll first want to remove any versions of the assemblies you have built before.
-
-```
-D:\git\coreclr> rmdir /q /s binaries
-```
-
 We build ```mscorlib.dll``` out of the coreclr repository and the rest of the framework that we'll need out of the corefx repository.  For mscorlib (from a regular command prompt window) run:
 
 ```
@@ -57,7 +49,7 @@ D:\git\corefx> build.cmd /p:OS=Unix /p:SkipTests=true
 
 It's also possible to add ```/t:rebuild``` to the build.cmd to force it to delete the previously built assemblies.
 
-For the purposes of Hello World, we need to copy over both ```bin\Unix.AnyCPU.Debug\System.Console\System.Console.dll``` and ```bin\Unix.AnyCPU.Debug\System.Console\System.Diagnostics.Debug.dll```  into the runtime folder on Linux. (e.g ```~/coreclr-demo/runtime```).
+For the purposes of Hello World, we need to copy over both ```bin\Unix.AnyCPU.Debug\System.Console\System.Console.dll``` and ```bin\Unix.AnyCPU.Debug\System.Diagnostics.Debug\System.Diagnostics.Debug.dll```  into the runtime folder on Linux. (e.g ```~/coreclr-demo/runtime```).
 
 After you've done these steps, the runtime directory on Linux should look like this:
 
@@ -91,24 +83,25 @@ Make a ```packages.config``` file with the following text:
 ```
 <?xml version="1.0" encoding="utf-8"?>
 <packages>
-  <package id="System.Console" version="4.0.0-beta-22512" />
-  <package id="System.Diagnostics.Contracts" version="4.0.0-beta-22512" />
-  <package id="System.Diagnostics.Debug" version="4.0.10-beta-22512" />
-  <package id="System.Diagnostics.Tools" version="4.0.0-beta-22512" />
-  <package id="System.Globalization" version="4.0.10-beta-22512" />
-  <package id="System.IO" version="4.0.10-beta-22512" />
-  <package id="System.IO.FileSystem.Primitives" version="4.0.0-beta-22512" />
-  <package id="System.Reflection" version="4.0.10-beta-22512" />
-  <package id="System.Resources.ResourceManager" version="4.0.0-beta-22512" />
-  <package id="System.Runtime" version="4.0.20-beta-22512" />
-  <package id="System.Runtime.Extensions" version="4.0.10-beta-22512" />
-  <package id="System.Runtime.Handles" version="4.0.0-beta-22512" />
-  <package id="System.Runtime.InteropServices" version="4.0.20-beta-22512" />
-  <package id="System.Text.Encoding" version="4.0.10-beta-22512" />
-  <package id="System.Text.Encoding.Extensions" version="4.0.10-beta-22512" />
-  <package id="System.Threading" version="4.0.0-beta-22512" />
-  <package id="System.Threading.Tasks" version="4.0.10-beta-22512" />
+  <package id="System.Console" version="4.0.0-beta-22703" />
+  <package id="System.Diagnostics.Contracts" version="4.0.0-beta-22703" />
+  <package id="System.Diagnostics.Debug" version="4.0.10-beta-22703" />
+  <package id="System.Diagnostics.Tools" version="4.0.0-beta-22703" />
+  <package id="System.Globalization" version="4.0.10-beta-22703" />
+  <package id="System.IO" version="4.0.10-beta-22703" />
+  <package id="System.IO.FileSystem.Primitives" version="4.0.0-beta-22703" />
+  <package id="System.Reflection" version="4.0.10-beta-22703" />
+  <package id="System.Resources.ResourceManager" version="4.0.0-beta-22703" />
+  <package id="System.Runtime" version="4.0.20-beta-22703" />
+  <package id="System.Runtime.Extensions" version="4.0.10-beta-22703" />
+  <package id="System.Runtime.Handles" version="4.0.0-beta-22703" />
+  <package id="System.Runtime.InteropServices" version="4.0.20-beta-22703" />
+  <package id="System.Text.Encoding" version="4.0.10-beta-22703" />
+  <package id="System.Text.Encoding.Extensions" version="4.0.10-beta-22703" />
+  <package id="System.Threading" version="4.0.10-beta-22703" />
+  <package id="System.Threading.Tasks" version="4.0.10-beta-22703" />
 </packages>
+
 ```
 
 Then grab NuGet (if you don't have it already)
@@ -139,7 +132,7 @@ ellismg@linux:~/coreclr-demo/runtime$ curl -O https://raw.githubusercontent.com/
 Then we just need to build it, with ```mcs```.  Because we need to compile it against the .NET Core surface area, we have to pass references to the contract assemblies we restored using NuGet:
 
 ```
-ellismg@linux:~/coreclr-demo/runtime$ mcs /nostdlib /noconfig /r:../packages/System.Console.4.0.0-beta-22512/lib/contract/System.Console.dll /r:../packages/System.Runtime.4.0.20-beta-22512/lib/contract/System.Runtime.dll HelloWorld.cs
+ellismg@linux:~/coreclr-demo/runtime$ mcs /nostdlib /noconfig /r:../packages/System.Console.4.0.0-beta-22703/lib/contract/System.Console.dll /r:../packages/System.Runtime.4.0.20-beta-22703/lib/contract/System.Runtime.dll HelloWorld.cs
 ```
 
 Once that's complete, we're ready to run Hello World!  To do that, we run corerun passing the path to the managed exe we want to run plus any arguments.  The HelloWorld from corefxlab will print Tux if we pass "linux" as an argument, so:
@@ -148,11 +141,4 @@ Once that's complete, we're ready to run Hello World!  To do that, we run coreru
 ellismg@linux:~/coreclr-demo/runtime$ ./corerun HelloWorld.exe linux
 ```
 
-Over time, we want this process to get easier. We would like to remove the dependency on having to compile managed code on Windows. For example, we are working to get our NuGet packages to include both the Windows and Linux versions of an assembly, so you can simply nuget restore the dependencies. Pull Requests to allow building CoreFX and mscorlib on Linux via Mono would be very welcome. A sample that builds Hello World on Linux using the correct references but via XBuild or MonoDevelop would also be great! Some of our processes (e.g. the mscorlib build) rely on Windows specific tools, but we want to figure out how to solve these problems for Linux as well. There's still a lot of work ahead, so if you're interested in helping, we're ready for you!
-
-# Using Docker
-
-If you don't want to do the above, or you can't (since you don't have access to Windows in order to build the managed components), I've produced a few helpful docker images to play around with.  There are not any plans to update these long term, but they should be useful in order to try things out.
-
-* ```ellismg/coreclr-demo:runtime-only``` Contains the runtime and managed components plus hello world.  Everything is located at ```/root/coreclr-demo```
-* ```ellismg/coreclr-demo:dev-environment``` Contains the managed components as well as the development tools for building the native runtime plus mono for building managed code locally.  Note this doesn't include the reference assemblies and other files in the packages directory since they can be downloaded on Linux using NuGet on mono, however a sample packages.config is present in ```/root/coreclr-demo/packages```.  In order to get this to work, you'll need to clone the git repository and build CoreCLR yourself and place the output in ```/root/coreclr-demo/runtime```.  You'll also need to go through the NuGet restore steps above, and build HelloWorld.exe yourself, but you don't need access to a Windows machine as the docker image already contains mscorlib.dll and System.Console.dll.
\ No newline at end of file
+Over time, we want this process to get easier. We would like to remove the dependency on having to compile managed code on Windows. For example, we are working to get our NuGet packages to include both the Windows and Linux versions of an assembly, so you can simply nuget restore the dependencies. Pull Requests to allow building CoreFX and mscorlib on Linux via Mono would be very welcome. A sample that builds Hello World on Linux using the correct references but via XBuild or MonoDevelop would also be great! Some of our processes (e.g. the mscorlib build) rely on Windows specific tools, but we want to figure out how to solve these problems for Linux as well. There's still a lot of work ahead, so if you're interested in helping, we're ready for you!
\ No newline at end of file