Skip to content

Building from source

antont edited this page May 16, 2011 · 2 revisions

(copy-pasted from http://wiki.realxtend.org/index.php?title=Building_Naali_from_source_trunk and updated here)

Table of Contents

Get the code from GitHub

 git clone http://github.com/realXtend/naali.git

Currently the development version is in the 'tundra' branch, we are in the process of merging it to develop. Do this to use that branch:

 git checkout -b tundra origin/tundra

Then get the dependencies and build according to the instructions for your operating system below:

WINDOWS

Introduction

The Naali viewer codebase uses CMake as its build system, so to generate the project solution files for Microsoft Visual Studio 2008 to use, you need to install CMake from http://www.cmake.org/. To be able to build the source repository, the first thing you need to do is to obtain (and possibly compile) the dependencies that are required by Naali. The second step is to configure the CMake build script to locate those dependencies, and finally you can compile the viewer solution itself.

Microsoft Visual C++ 2005 or earlier versions are not officially supported (but might work).

  • Note: This tutorial will not provide instructions on how to use svn in general or how to use any individual SVN clients. One easy to learn client that we recommend is Tortoise SVN.
  • Note: This tutorial will use concrete example paths like C:\Naali_trunk and C:\Naali_deps for readability and easier understanding. You can always choose your own paths in you local hard drive.

Acquiring the viewer source code

  1. NOTE: The code was moved to github in early 2010, see http://github.com/realXtend/naali/ for the current version.
  1. Create the following directory structure to your hard drive C:\Naali_trunk
  2. Do a git checkout from git://github.com/realXtend/naali.git to C:\Naali_trunk.

Acquiring the dependencies

You will need two sets of dependencies, build and runtime dependencies. They are provided via a SVN repository so that they are easily updated and changes can be tracked properly. Second option is to build the dependencies yourself from source.

Getting dependencies from SVN repository

  1. Create the following directory structure to your hard drive C:\Naali_deps
  2. Do a svn checkout from http://realxtend-naali-deps.googlecode.com/svn/ to C:\Naali_deps.

Setting Windows environment variables for cmake

You need to create new windows environment variables so that cmake will find the correct dependency paths when doing the prebuild step. For more info check this page.
Windows Vista and 7
  1. Right-Click Computer -> Properties from your desktop. Or go to Control Panel -> System and Security -> System
  2. Click "Advanced System Settings" link from the left panel
  3. Click "Environment Variables..." button from the bottom
  4. There are two list views, click the below ones (System Variables area) "New..." button
    1. Variable name: NAALI_DEP_PATH
    2. Variable value: C:\Naali_deps\bin\build_deps
    3. Click the OK button
  5. Click the OK button from all open dialogs
Windows XP
  1. Right-Click My Computer -> Properties from your desktop. Or go to Control Panel -> System
  2. Go to the Advanced tab
  3. Click "Environment Variables..." button from the bottom
  4. There are two list views, click the below ones (System Variables area) "New..." button
    1. Variable name: NAALI_DEP_PATH
    2. Variable value: C:\Naali_deps\bin\build_deps
    3. Click the OK button
  5. Click the OK button from all open dialogs

Getting dependencies by building from source

Use this option when you need to be able to generate custom builds of the dependency packages or if you want to have better debugging capabilities in VS (breakpoints, step through, trace, edit-and-continue inside dependency libraries). This process is much more involved, but allows you to have a lot less boundaries when developing. Note that not all of the external dependencies are included in this repository, since the large size of the resulting codebase forbids that. To build Naali using the dependency repository, perform the following:
  1. Get the viewer dependency repository by executing 'svn checkout http://realxtend-naali-deps.googlecode.com/svn/trunk/'. The following assumes that you checked out the dependencies into the folder C:\Naali_deps\src.
  2. Download, install and build Boost from http://www.boost.org/. Version v1.36.0 or newer is required.
  3. Download, install and build Qt from http://www.qtsoftware.com/, or obtain Qt from the precompiled dependency package. Check that the environment variable QTDIR is correct. See \viewer\doc\build-qt-windows.txt for more details.
  4. Download, install and build Ogre from http://www.ogre3d.org/. Alternatively complete this dependency using the precompiled dependency package. Ogre version v1.6.1 or newer is required. Check that OGRE_HOME environment variable points to the installation root folder.
  5. Download, install and build PoCo from http://pocoproject.org/. Version v1.3.4 or newer is required. It seems that Visual Studio 2008 Express cannot be used to compile PoCo, so in that case, you just have to get the precompiled version from the dependency package.
  6. See viewerdeps\src\expat\ReadmeRex.txt. Build Expat from C:\Naali_deps\src\expat\expat.sln. Copy the outputted DLLs to viewer\bin.
  7. See C:\Naali_deps\src\GnuWin32\ReadmeRex.txt. LibIconv doesn't require building. Copy the DLLs in viewerdeps\src\GnuWin32\bin\ to viewer\bin.
  8. See C:\Naali_deps\src\libcurl\ReadmeRex.txt. Build LibCurl from the file vc9curl.sln. Copy the resulting outputted DDLs to viewer\bin.
  9. Build OpenJPEG from C:\Naali_deps\src\OpenJPEG\LibOpenJPEG.sln. Copy the resulting outputted DLLs to viewer\bin.
  10. See C:\Naali_deps\src\xmlrpc-epi\ReadmeRex.txt. Build XMLRPC-EPI from C:\Naali_deps\src\xmlrpc-epi\xmlrpcepi.sln. Copy the resulting outputted DLLs to C:\Naali_trunk\bin.
  11. Continue from Building the Viewer below.

Building the Viewer

Copying runtime dependencies

  1. Copy the whole content of C:\Naali_deps\bin\runtime_deps to C:\Naali_trunk\bin
    • Note: Windows will ask if you want to override files. Go ahead and override, but if it asks specificly if you want to override contect of '.svn' folder(s) then select no.

Configuring modules

You can include/exclude certain modules from Naali by editing the cmake files in the trunk folder. This can be handy if some optional module is giving you problems or you want to try additional modules that are not included in the default setup etc.

  1. Open up C:\Naali_trunk\CMakeLists.txt in your preferred text editor
  2. Configure the set of modules that you want to build by commenting out the unnecessary ones. Read the comments inside the text file for more information what are your options
  3. Remember that you need to run cmake_vs2008.bat again every time you make modifications to this file in order for them to affect the solution file.

Prebuild with cmake

This step will create the Visual Studio solution file from the source files. Cmake will find needed dependencies from enviroment variable NAALI_DEP_PATH that you just created and include them in the individual projects include folders for headers and libs. Make sure that cmake\bin is in your PATH before executing cmake_vs2008.bat, easiest way to do this is to check the option "include cmake in system PATH" while installing cmake.

  1. Run C:\Naali_trunk\cmake_vs2008.bat. If the cmake window gives any errors, try to determine what dependencies are missing and go back to previous steps.
  2. If cmake prints out to the bottom Build files have been written to: C:\Naali_trunk the prebuild step was successful.
  3. Press any key to close the window
  • Note: Before cmake_vs2008.bat runs cmake.exe it will set QTDIR to our dependecies Qt directory. This is done so you don't manually have to set the env variable. If you have QTDIR set for your other dev reasons this step will not affect it. SET QTDIR=%NAALI_DEP_PATH%\Qt only is in effect for the runtime of the cmake_vs2008.bat.

Building and running the Naali viewer in Visual Studio

  1. Open the created solution file C:\Naali_trunk\naali-viewer.sln by double clicking or open it from inside Visual Studio
  2. Select debug or release mode from Visual Studio
  3. Setting working directory: Right Click on the subproject viewer -> Properties -> From the dialog go to Debugging -> Set Working Directory to C:\Naali_trunk\bin. Remember to do this for both debug and release.
  4. Setting the run command: In order for QApplication to find the qt.conf file from C:\Naali_trunk\bin so it will know where qt plugins are located, do the following: Right Click on the subproject viewer -> Properties -> From the dialog go to Debugging -> Set Command to $(SolutionDir)\bin\$(TargetFileName). Remember to do this for both debug and release. If you don't do this, running from visual studio Qt DLLs wont find the plugins as the path was not added via qt.conf file. This is not dangerous though, Naali will run normally but you just wont see images and foreign fonts in QWebView. When running viewer*.exe from naali/bin the plugins will be found due the execute path is correct.
  5. Click from the top menu Build -> Build Solution (the usual short key for this operation is F6 or F7)
  6. Wait while it builds and check that no errors occurred while building. If there are errors and its about not finding dependencies go back to previous steps as needed.
  7. When build is complete without errors click from the top menu Debug -> Start Debugging (the usual short key for this operation is F5)
  • Note: When compiling for the first time, compile in debug mode and run the exe at least once. Some data files are created in debug mode which are needed when running in release mode.
 '''Created DLL files'''
 <tt>C:\Naali_trunk\bin\modules\core</tt>
 '''Created EXE files'''
 Release: <tt>C:\Naali_trunk\bin\viewer.exe</tt>
 Debug: <tt>C:\Naali_trunk\bin\viewerd.exe</tt>
 '''Python Modules'''
 <tt>C:\Naali_trunk\bin\pymodules</tt> read the readme.txt from this folder for more information.

LINUX

Ubuntu

Run the tools/build-ubuntu-deps.bash script. It should automagically build the dependencies and naali itself. It should be up to date as our buildbot uses it, i.e. it is ran after any commit to the repository.

If all went well, you can try running the viewer:

 cd bin
 ./viewer

Other distributions

You can use the Ubuntu script as a reference to see what packages are needed, and what is installed directly from sources: https://github.com/realXtend/naali/blob/tundra/tools/build-ubuntu-deps.bash

Many of the dependencies such as Telepathy (for XMPP), gstreamer, Caelum and Python (and hence PythonQt) are optional and can be omitted. You can configure what modules are built, and therefore what dependencies are needed, using CMakeBuildConfig.txt

Ports of the built script to other distributions and packaging would be very welcome!

Troubleshooting

"make VERBOSE=1" lets you see the command lines the build system is using.

ArchLinux

  • Get the Naali source code and dependencies from GIT:
 git clone http://github.com/realXtend/naali.git ~/src/naali
 svn checkout http://realxtend-naali-deps.googlecode.com/svn/trunk/ ~/src/naali-deps
  • Make sure yaourt is installed
  • Install dependencies from the archlinux repositories and AUR:
 pacman -S ogre telepathy-gabble telepathy-farsight
 yaourt -S xmlrpc-epi 
 yaourt -S poco
 yaourt -S python26
  • Install PythonQT
 cd ~/src/naali-deps
 wget http://sourceforge.net/projects/pythonqt/files/pythonqt/PythonQt-2.0.1/PythonQt2.0.1.zip/download
 unzip PythonQt2.0.1.zip
 mv PythonQt2.0.1 PythonQt
 cd PythonQt
 qmake
 vim generated_cpp/com_trolltech_qt_core/com_trolltech_qt_core0.h 
  • Remove CocoaRequestModal = QEvent::CocoaRequestModal from the eventlist(Doesn't work with qt 4.7)
  • Refer to python.
 export PYTHON_PATH = /usr/bin
 export PYTHON_LIB  = /usr/lib/python2.6/
  • Compile PythonQt
 make all
  • Compile qt property editor
 cd ~/src/naali-deps
 mv qtpropertybrowser-2.5_1-opensource/ QtPropertyBrowser
 cd QtPropertyBrowser
 chmod +x ./configure
 ./configure -library
 qmake
 make