I'd like to know how I would build Unity from source code in the current development release. Please cover the following topics:
- Which packages are needed to compile Unity?
- Where would I get the current source code?
- What are the steps to actually configure and compile Unity?
- Is it possible to safely run the latest version alongside the version from the repositories?
Best Answer
Building Unity from Source
In this guide you will build a separated version of Unity trunk (locally installed to your home directory), so you don't need to worry about corrupting the version from the Ubuntu repositories and you also won't need to get root permissions throughout the whole process (except for installing the build dependencies).
0. Installing build dependencies
You'll need to run this once to install all necessary build dependencies:
If you have source code repositories (aka
deb-src
) enabled, you can instead use:1. Preparing the environment
Replace
SOURCE
andPREFIX
with the directories you'd like the source and build files to go. In this example I put both in my home directory:2. Building Nux
You will probably need to grab the latest version of
Nux
to get Unity trunk to compile:Tip: Most modern desktops and laptops have several cores. You can greatly speed up the compilation by taking advantage of this. The
make
command has build-in support for this which you can activate using the -jN switch where N is the number of jobs to run in parallel. A good rule of thumb is to run 2 times the number of cores on your processor. Thus, on a normal dual core computer you should runmake -j4
to minimize the compilation time.3. Building Unity
Now grab the latest Unity code and build it:
That's it, log out and back in again and you should be running the latest Unity. Alternatively, you can run
4. Updating
Make sure to prepare the environment like described in step 1, then simply enter both top-level directories
nux
andunity
, runbzr pull
, rebuild, and reinstall.I suggest removing and recreating the
build
directory in theunity
directory, to make sure no old files are messing with your build.5. Removing Unity
Remove the three directories
$SOURCE
,$PREFIX
and~/.compiz-1
.Useful Link: