Difference between revisions of "BuildTheCode"

From Sirikata Wiki
Jump to: navigation, search
(Move requirement of installing cmake to a single overview section, add section about subversion.)
(Remove note about Frameworks directory since its checked directly into git now.)
Line 126: Line 126:
  
 
When the build completes you should have the libraries, plugins, and binaries in sirikata/build/cmake.
 
When the build completes you should have the libraries, plugins, and binaries in sirikata/build/cmake.
 
=== Mac Notes ===
 
For the mac, you must make a symbolic link one level above cmake, to the Frameworks directory in dependencies. This is required to emulate the structure of a Mac Application which has Frameworks one level above the MacOS binary directory.
 
 
  cd sirikata/build
 
  ln -s ../dependencies/Frameworks
 
  
 
=== Snow Leopard ===
 
=== Snow Leopard ===

Revision as of 04:47, 23 November 2009

Dependencies

Sirikata depends on quite a bit of external libraries. Dependencies gives a list of required and optional libraries and a brief description of how they are used.

When building Sirikata you have two options: handle installing dependencies yourself or use our install scripts or precompiled binaries (depending on platform and library) to help you build and install the required libraries. If you want to perform the installation or need to write new scripts for a new platform, see Dependencies for instructions on how to do so.

These instructions explain how to use our install script or precompiled binaries.

Note Some dependency files are quite large, especially the precompiled binaries. When you run the install commands, it may appear the script has hung, but its likely just checking out the packages.

Note Throughout we'll be using the standard set of dependencies, which includes support for graphics, embedded browsers, .NET scripting via Mono, Python scripting via IronPython, and physics simulation via Bullet. If you don't need all these features, for example because you are only running the space server, you can use a different dependency target. Where depends is used, you can replace the following to get a different set of dependencies:

  • minimal-depends - the minimal dependencies required to get the system building
  • minimal-graphics-depends - the minimal dependencies required to get 3D graphics working, i.e. to get a client running. Note that not all features of the client will be enabled by this
  • full-depends - all dependencies, enabling all features of the system, and enables use of root to install system packages

CMake

We use CMake on all platforms to check for dependencies and generate a build script. The Linux dependencies will install CMake from your system's package manager if you allow it to use root. Otherwise and for all Mac and Windows platforms, CMake is not installed automatically. You should use the install tool from the CMake website or install it using your system's package manager. CMake 2.4 or higher is required, CMake 2.6 or higher is preferred.

Subversion

Because of their size, dependencies are stored in subversion repositories. If you want to use our automated dependency scripts, you'll need Subversion installed. It is installed on Mac by default, Linux users can use their distributions system package, and Windows users can either install it via Cygwin or use TortoiseSVN.

Windows

Using Cygwin (easy)

Windows never requires root access or build tools; all dependencies are binaries that are installed into your source tree (under sirikata/dependencies). To install simply run these commands in a Cygwin bash shell:

 cd sirikata/
 make depends

You should now have a sirikata/dependencies directory containing all the dependencies.


Without Cygwin (manual)

While Cygwin is a useful tool, the requirement of a Cygwin installation for the windows compile is not necessary.

You will need to install a SVN client. Then, checkout:

http://sirikatawin32.googlecode.com/svn/trunk/ for Visual Studio 2008

and name that directory "dependencies".

If using a command-line SVN client, run "svn co http://sirikata.googlecode.com/.../win32vc9 dependencies"

Then, go into the dependencies folder and unzip all of the packages directly into the dependencies directory. Make sure to select "Extract Here"--if that option is not available, in the extraction dialog, remove the name of the zip file from the end, so it just ends with "dependencies". The extracted directories should not have the same name as the zip files.

Mac

Most dependencies are binaries that are installed into your source tree (under sirikata/dependencies). To install simply run the commands:

 cd sirikata/
 make depends

You should now have a sirikata/dependencies directory containing most of the dependencies.

To get the last dependency please download Mono 2.4 or later from the mono website http://www.mono-project.com/ And invoke the installer .pkg. This installer will place a Mono.frameworks folder in /Library/Frameworks

Linux

Currently the install script expects an Ubuntu system, 8.04 or greater. There are three modes of installation - basic, full, and minimal. The basic mode will install everything it can within the source tree and won't try to install any system libraries (i.e. it assumes you have already installed libraries for which the system provided versions are sufficient). This is useful if you just need to get the custom dependencies in a new clone, having already built Sirikata before.

The dependencies are actually stored on an svn server, so first make sure you have svn installed:

 sudo apt-get install subversion

To install using the basic mode issue these commands:

 cd sirikata/
 make depends

Make sure you have the latest submodules

 git submodule init
 git submodule update

Building Sirikata

We use CMake to generate our build scripts. Make is used on Mac and Linux and Visual Studio is used on Windows to perform the actual build. All three builds follow the same basic steps:

  • Run cmake, possibly modifying the configuration.
  • Run your build tool.

Windows

Start up CMake and point both paths to sirikata/build/cmake. Hit configure twice. If you installed any dependencies in non-standard locations, point CMake to them now. To generate the build files, hit OK.

Now browse to sirikata/build/cmake. Open Sirikata.sln and run Build All.

This should result in all libraries, plugins, and binaries in the sirikata/build/cmake/debug or sirikata/build/cmake release, depending on which configuration you built.

Notes

  • There aren't standard locations to search for dependencies on Windows. Obviously we've setup the build system to work cleanly with the dependency install script. The easiest way to get a manual installation of dependencies on Windows to work is to use the same layout as the install script, where all dependencies are located in sirikata/dependencies. If you don't do this, you will almost certainly need to manually specify the locations of some libraries in CMake.
  • The build is known to work for VS2005 and VS2008. However, be aware that for VS2005 you must have the latest service pack installed.
  • If you get error 0xc0000022, check the permissions of the sirikata top-level directory. If you used Cygwin's version of git, it will remove execute permissions for security purposes. You may enable execute by doing "chmod -R +x sirikata" in cygwin, or Granting yourself Full Control in Right Click->Properties->Security (make sure to click the Replace All Entries in Child Objects checkbox).

DLL Path under windows

[If you get a message saying anything like 0xc0150002, "failed to initialize properly", "the runtime asked to terminate", or about "reinstalling the application": If you use Visual Studio 2005, you must have Service Pack 1 installed. Also, you may need to install the "Visual C++ Redistributable Package".]

In order to get Sirikata to find the required DLLs, you must copy all DLL files from these directories into the "build/cmake" directory:

  • dependencies\boost_1_37_0\lib
  • dependencies\installed-curl
  • dependencies\ogre-1.6.1\bin
  • dependencies\SDL-1.3.0\bin
  • dependencies\protobufs\bin

Note that Sirikata currently does not work in Windows 2000, due to the lack of a few raw input functions (RegisterRawInputDevice) that SDL 1.3 uses. This will hopefully be fixed in SDL at some point to make it use the old DirectX raw input system.

Mac and Linux

For convenience we provide a top level makefile which performs the standard build operations. If you want a default build and have used the install script for dependencies, do:

 cd sirikata/
 make

If you'd like to run the build manually, do the following (essentially what is in the makefile):

 cd sirikata/build/cmake
 cmake . [-DCMAKE_BUILD_TYPE=Debug|Release]
 make

To interactively adjust settings, for instance to point CMake to a different version of libraries:

 cd sirikata/build/cmake
 ccmake .

When the build completes you should have the libraries, plugins, and binaries in sirikata/build/cmake.

Snow Leopard

(in progress - not fully debugged yet)

With the release of Apple's Snow Leopard (10.6) operating system comes the opportunity to have software compiled for two different architectures running on the same machine. These are the 32-bit i386 and the 64-bit x86_64 (k8). Though the Intel hardware has always had the capability to run in a 64 bit address space prior to 10.6, the operating system didn't support it. Unfortunately, the default architecture is 64, but not all libraries and dependencies are 64-bit savvy, so it is best to compile for the 32 bit architecture.

Upgrade Xcode and Developer Tools

First, you need to upgrade the Xcode tools to 3.2.x. On the Snow Leopard DVD, under “Optional Installs”, install “Xcode.mpkg” to get 3.2. Use all default options. Alternatively, you may want to log in and download the latest Xcode at

http://developer.apple.com/mac/

This is highly recommended, because the initial Xcode 3.2 seems to get into a spinning beachball state a bit too frequently. Xcode 3.2.1 seems to be a better multitasking citizen.

Upgrade MacPorts

Then, you need to upgrade Macports. Get the Snow Leopard disk image at

http://www.macports.org/install.php

After successful installation, make sure to run

sudo port selfupdate

Then, you need to remove all of your ports, and reinstall new ones. See the documentation at:

http://trac.macports.org/wiki/Migration

By default, the libraries and frameworks are compiled for the 64-bit architecture, so you need to use the +universal flag to produce both 32- and 64-bit variants.

sudo port install cmake +universal zlib +universal bzip2 +universal boost +universal sqlite3 +universal
Regenerate Makefiles
cd build/cmake
rm CMakeCache.txt
cmake . -DCMAKE_CXX_FLAGS="-arch i386"

Now, you should be able to build.

Mac XCode Project

Many mac developers prefer to use the XCode programming environment. To do this, cmake will need to be configured to use XCode


Steps are:

  1. test -d build/cmake/Debug || mkdir build/cmake/Debug
        1. The directory for XCode build products
  2. python csv_converter.py build/cmake/Debug/scene.csv scene.db
        1. Generate a scene for use by the XCode project
  3. cd build/cmake
  4. ln -s ../../dependencies/Frameworks Frameworks
        1. to fix brittle paths in Xcode project.
  5. cmake -G Xcode .
  6. cd Debug
  7. ln -s ../Sirikata.Protocol.dll Sirikata.Protocol.dll
  8. ln -s ../Sirikata.Runtime.dll Sirikata.Runtime.dll
  9. cd ..
  10. launch Xcode
  11. open Sirikata.xcodeproj
  12. edit project settings
        1. general tab
        2. choose project root
        3. select build/cmake directory. click ok. value should just be <Project File Directory>.
              1. This fixes problem that prevents debugger from working.
  13. project menu
        1. select active target ALL_BUILD
        2. select active project executable cppoh
        3. select active build configuration Debug
  14. close XCode to save the project
  15. reopen Sirikata.xcodeproj
  16. build it
  17. Debugger
        1. Confirm that you can set a break point.
        2. Run debugger
        3. Confirm that it stops at a break point.
        4. Confirm that it displays source code.
        5. (trouble shoot back to step 10)

Running Sirikata

Assuming the previous steps have completed successfully, you should have a few binaries built and you are ready to run Sirikata.