Imprudence:Compiling

Our modest attempt at a tutorial for compiling the Second Life / Imprudence code. Please correct any errors or missing information.

On Linux

 * CMake 2.4.8 (newer versions seem not to work right)
 * Python
 * The standard stuff: gcc, make, tar, etc.

On MacOS X

 * OS Leopard (10.4) or Tiger (10.5)
 * Xcode 2.4 if you have Leopard, or 3.0 or greater if you have Tiger. Free to download (though a rather large download), you just need sign up for a free ADC membership. Or if you have your MacOS X installer disc lying around somewhere, that should have a copy of Xcode on it.
 * CMake 2.4.8 or greater

On Windows

 * Visual Studio 2005 or 2008 (preferably 2005). You can download Visual C++ Express 2005 and SP1 (SP1 for Vista) or Visual C++ Express 2008 for free. If you are a student, you can also download Visual Studio 2005/2008 Professional for free through dreamspark.
 * CMake 2.6.2 (or greater). Add CMake to the system PATH.
 * ActivePython 2.5 or 2.6.
 * Cygwin. Make sure patchutils, flex, and bison are included under "devel".
 * Microsoft DirectX SDK November 2008. Install Headers and Libs.
 * Windows SDK 6.1. The only required portion is Developer Tools > Windows Headers and Libraries.

Downloading the Viewer Source Code & Artwork
Imprudence source code is available online:
 * From the Downloads page
 * Or, from the Git repository (If you know how to use Git.)

Or, you can practice compiling with the SL source 1.21.6:
 * Linux/Mac
 * Windows

You also need to download the artwork and libs:
 * Artwork (this same file works for all operating systems)
 * Libs:
 * Linux
 * Mac
 * Windows

The source, artwork, and libs packages should all have a "linden" folder inside them. The contents of those should be combined together into one "linden" folder, so they can be together as one nice little family. How you do that depends on your operating system.


 * Linux: Unpack all the packages from within a single directory, or use the command:  (where artwork, libs, and source are the directories where you unpacked those packages.)
 * Mac: Open a Terminal and use the command:  (where artwork, libs, and source are the directories where you unpacked those packages.)
 * Windows: Drag all the 'linden' directories into the same directory, and use the "Replace" option to combine them.

Generating Project Files & Auto-downloading Libraries
Once all that is gathered together, the next step is to run the command to generate the project files. This will also automatically download some software library files for the Viewer to compile with.


 * Linux & Mac: Open up a terminal (on Mac, that's Applications > Utilities > Terminal, I believe), change directory (or "cd") to the  directory and run the "develop.py" program. This example assumes you put the linden directory inside the directory  :

cd "/Users/MyName/Imprudence/linden/indra/" python develop.py


 * Windows: If you installed ActivePython, you can just open up the  directory and double-click on "develop.py". If you have multiple versions of Visual Studio installed, you can use the -G flag to tell cmake which version you want to use by running develop.py from the command line, e.g.:   where:


 * VC71 = VS2003
 * VC80 = VS2005
 * VC90 = VS2008

The develop.py command will do a few things:


 * 1) Automatically download a bunch of software libraries and unpack them in the linden/libraries/ folder to be used later when compiling. This will take a while, depending on the speed of your internet connection, but the good news is it only has to download once, not every time you compile.
 * 2) Create project files to use for compiling with Visual Studio (on Windows), XCode (on Mac), or Make (on Linux). CMake creates a separate directory for compiling and storing the project files. The exact directory name depends on your operating system, processor type (e.g. Intel vs PPC), and/or Visual Studio version (for Windows):
 * 3) * Linux:  (e.g.  )
 * 4) * Mac:  (e.g.  )
 * 5) * Windows:  (e.g.  )

Compiling
Now for the actual compiling! The instructions here are different for each operating system, because of the different software they use.

Note: Compiling the first time can often take a few hours, so you should start it running and then take a nap, read a book, or whatever you please. You may want to check in from time to time to make sure it hasn't had an error.

On Linux
From the  directory, run:

python develop.py build

This will go through and compile everything. The final product goes into. There will also be a  file in newview containing the same contents as the   directory.

On Mac
Open up the  directory. Inside will be a "Second Life.xcodeproj" or "Imprudence.xcodeproj" file, depending on which code you've downloaded. Load that up in Xcode. Next, click the Info button and change the architecture to Universal 32-bit. (If that's not an option for your version of Xcode, you can skip that step.) Now click the Run button, and it should start compiling!

The final product goes into (I think). Please edit this article if I'm mistaken.

On Windows
(Visual Studio 2005 is the default compiler for Imprudence. Feel free to post about issues using the Express Editions or 2008 in the development forums.)


 * 1) After develop.py has completed, browse to your newly created   directory (where   is your Visual Studio version number). Inside, there will be either a "SecondLife.sln" or "Imprudence.sln" file, depending on which code you've downloaded (from here on out, we'll assume you're compiling Imprudence, although the process is the same for both). Double click on Imprudence.sln to open it in Visual Studio.
 * 2) The default StartUp Project should be "imprudence-bin" (you can tell because it's bold). If not, make it so by right clicking "imprudence-bin" and selecting "Set As StartUp Project".
 * 3) There will be three build options: ,  , and  . We recommend building  .
 * 4) After building, your final compiled .exe and dlls will be placed in  . Run Imprudence by clicking the "continue" button or pressing F5. If you want to run imprudence-bin.exe without relying on Visual Studio:
 * 5) Copy the folders and *.txt files from  to
 * 6) Double click imprudence-bin.exe.
 * If you make any changes to the files in  (such as editing an xml file) you'll need to copy them over again.


 * NOTE: Visual Studio 2005 does not support multi-core source compiling by default. To enable it, you need to use the /MP switch, which will significantly speed up compile times (for example /MP2 if you're using two cores).

Libraries
If you are feeling brave, you can compile the viewer's libraries for yourself.


 * Windows: see User:McCabe/Win_build for Imprudence-specific library compile instructions. Any library not yet there can be found here.

"RuntimeError: Path.... [some FMOD thingy] doesn't exist"
You might encounter this near the end of the compile process if you're compiling the Second Life code or an early batch of Imprudence code. The exact error message depends on your operating system:

On Linux, it looks like: RuntimeError: Path.... libfmod-3.75.so doesn't exist

On Mac: RuntimeError: Path.... libfmodwrapper.dylib doesn't exist

And on Windows: RuntimeError: Path.... fmod.dll doesn't exist

The problem: The compile process is trying to package up the fmod library so that it can be included in the installer package, but it can't find it!

Solution: If you're compiling Imprudence or an open source viewer that you intend to distribute to other people, the solution is to make the compile process skip that step entirely. FMOD is proprietary, so you can't legally distribute it -- including it would be pointless and dangerous!

To disable that step, open  in a text editor. The exact line to edit depends on you operating system:

On Linux, around line 611 or so: self.path("libfmod-3.75.so")

On Mac, around line 416 or so: self.path(self.args['configuration'] + "/libfmodwrapper.dylib", "libfmodwrapper.dylib")

On Windows, around line 170 or so: self.path("fmod.dll")

You should comment out that line of code by typing a '#' (pound/number/hash symbol) at the start of the line of code. For example, the Linux line would become:
 * 1) self.path("libfmod-3.75.so")

Save the  file and start the compile process again, and the error should not occur.

Removing Bad Libraries on Gentoo Linux
If you are running Gentoo Linux, you may need to remove some of the auto-downloaded libraries in order for the executable to successfully link at the end. From, remove:

libatk-1.0.so libgdk_pixbuf-2.0.so libgdk-x11-2.0.so libglib-2.0.so libGLU.so libGLU.so.1 libGLU.so.1.3.070002 libgmodule-2.0.so libgobject-2.0.so libgthread-2.0.so libgtk-x11-2.0.so libgtk-x11-2.0.so.0.400.14 libpango-1.0.so libpangoft2-1.0.so libpangox-1.0.so libpangoxft-1.0.so

This will cause the compile process to use the libraries installed on your system. So, you'll need to have these installed via portage:

dev-libs/atk dev-libs/glib media-libs/mesa x11-libs/gtk+ x11-libs/pango