Development Environment Setup

From OpenMW Wiki
Revision as of 11:27, 15 March 2012 by Corristo (talk | contribs) (updated build instructions for OS X)
Jump to navigation Jump to search

This page will describe how to set a dev env for several OSes. Please note that it is a work in progress and that it will be reliable only once each platform is marked as [TESTED].

You might also want to read the GitHub FAQ first.

Third-Party Libraries and Tools

  • OpenMW currently uses the following libraries:
    • OGRE 1.7.x - the main graphic engine
    • OIS - a cross-platform C++ input handling library
    • MyGUI - the in-game windows and menus
    • Audiere and OpenAL - for sound support
    • Bullet - the physics engine
  • OpenMw additionally uses the following tools:
    • CMake - used to manage the build process
    • Git - used as the source control management system

For those unfamiliar with Git, the Sphere RPG Engine group has a fairly useful short wiki page entitled "Git for the lazy". Make sure to also check out the GitHub FAQ.

Windows

Visual Studio 2008/2010

Tools

  • Visual Studio 2008/2010 - normal or free express versions.
  • Cmake: CMake v2.8
  • Git - Our version control software: The file you want is Git-1.7.1-preview20100612.exe found HERE.

Libraries

  • Ogre: Choose OGRE v1.7.1 SDK for Visual Studio 2008 or 2010]
  • Boost: Boost lib used by OGRE but perhaps you should set it manually, in OGRE, boost system, file_system, and program_options are missing, you should download the mt and mt-gd for vc90 and putt libs and dll in your OgreSDK_vc9_v1-7-1\boost_1_42\lib dir, they are in the boost-binaries\1.42.0 section in sourceforge download page. The boost source included in OGRE is missing filesystem and program_option, you should download them from boost sources and copy the directories in Ogre3D\boost_1_42\boost dir.
  • Freetype: Freetype2 and set the environment variable FREETYPE_DIR to the <install_path>
  • OIS
  • OpenAL
  • Audiere
  • GNU C compiler Library
  • libsndfile

Once this is done, you're ready to get the source code.

Download and install all of these and make sure the environment (the system and Cmake) knows where they are. (Coming soon) Once everything is installed properly, run the following command in the directory that you installed OpenMW's source to:

Running and using CMake

First, before opening Cmake, create a sibling directory called "OpenMW - build" next to the root "openmw" so that an out-of-source build can be done.

 "<Cmake's Install Directory>\bin\cmake.exe" ..\openmw -G "Visual Studio 9 2008"

Then you should update include dirs of project to add OGRE (<path_to_ogre>\include and <path_to_ogre>\include\OGRE).

Then you should include the correct path to needed libs (OgreSDK\lib & boost\lib) if not done by the CMake script. This may require first setting the OGRE_HOME environment, e.g. set OGRE_HOME=C:\OgreSDK.

At this point, you've got an exe generated, it needed OGRE dll to be run, the lazy way is to copy the OpenMW in OgreSDK\bin\debug that contains all needed files (dll en .cfg). In the same directory than the .exe, you should have the data directory of the Morrowind game - or alternatively, on Windows Vista or Windows 7, you can create a symbolic link to the data directory:

 C:\dev\omw\build>mklink /D data "c:\Program Files\Bethesda Softworks\Morrowind\Data Files"
 symbolic link created for data <<===>> c:\Program Files\Bethesda Softworks\Morrowind\Data Files

Git on Windows

via Cygwin

Git is available on Windows via cygwin. Git can be used directly on Windows instead of grabbing source zip files from Github. The cygwin environment will allow you to use the same git command line commands as are recommended for the Linux environment. Note however that the cygwin version of CMake does not appear to support VS2008 as a valid target; therefore, cygwin can only be used for Git commands and a standard Windows command prompt should be used for invoking CMake.

via msysGit

There is also a stand-alone compiled package called msysgit. This will give you a Cygwin-like console with the git command, which you may find easier than via Cygwin.


via TortoiseGit

There is also a GUI git client for the one used to TortoiseSVN or TortoiseCVS which is called TortoiseGIT. It will give you a nice GUI inside the Windows explorer. This is the easy way.

via eclipse

First of all, you need the egit plugin. Install it, restart eclipse, "file -> import -> git -> clone"

Linux

Arch Dependencies

There are two AUR packages available for OpenMW, a stable and a development version. They can be found at https://aur.archlinux.org.

Information about building packages from the Arch User Repository (AUR) can be found at the Arch wiki.

Ubuntu Dependencies

Key requirement

In order to install Ogre, you need to add ubuntu's packager for Ogre (Andrew Fenn) as trusted:

 sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 6F7E2F0B

note: "6F7E2F0B" is the id of Andrew Fenn.

In synaptic, go to settings -> Repositories -> add copy this into the field and click add source.

 ppa:andrewfenn/ogredev

within synaptic search for ogre and mark 1.7.1 for installation. click apply.

Packages

You will need g++ in order to compile OpenMW.

To setup a build environment and install all dependencies type:

 sudo apt-get install git libois-dev libopenal-dev libmpg123-dev libpng-dev libogre-dev \
 libsndfile1-dev libblkid-dev libfreeimage-dev libboost-filesystem-dev libboost-thread-dev \
 libboost-program-options-dev libboost-system-dev uuid-dev libqt4-opengl libqt4-dev \
 cmake build-essential

If there is a missing package, then it does not exist in your distribution's repository. This can happen with older versions. You will need to either find another source or build it yourself. Examples can be seen below.

Ogre
Boost libraries not included within the libogre-dev custom package.

Note: libboost-system-dev will be autoincluded in at least the filesystem package.

 libboost-filesystem-dev
 libboost-thread-dev
 libboost-program-options-dev

Install the development files for libogre-dev 1.7.1

Check

Do you have the 1.7.1 version?

 pkg-config --modversion --cflags OGRE

More information is available here on the custom libogre-dev package. https://launchpad.net/~andrewfenn/+archive/ogredev

Bullet

You will also need to install bullet package. You can install from source which can be found at http://www.bulletphysics.com or you can get the GetDeb version at http://www.playdeb.net .

It also uses the cmake build system and can be installed like:

 cmake .
 make
 sudo make install

Or the GetDeb version:

wget -q -O - http://archive.getdeb.net/getdeb-archive.key | sudo apt-key add -
sudo sh -c 'echo "deb http://archive.getdeb.net/ubuntu oneiric-getdeb games" >> /etc/apt/sources.list.d/getdeb.list'
apt-get update
apt-get install libbullet-dev

Fetching the source

 mkdir OpenMW
 
 cd OpenMW
 git clone git://github.com/zinnschlag/openmw.git
 cd openmw
 git submodule update --init
 cd ..

Building

With make

Note that this is an out-of-source build. Generally, this is the preferred method when working with cmake.

 mkdir Build
 cd Build
 cmake ../openmw/

This creates a regular makefile.

Normally you can just run 'make' but if you have multiple cores, you can increase your compile time by doing this:

make -j`getconf _NPROCESSORS_ONLN`

With codeblocks

If you want to create a Code::Blocks project instead, use these lines:

 mkdir Build
 cd Build
 cmake -G "CodeBlocks - Unix Makefiles" ../openmw/

Please note, that the Code::Blocks generator only generates a makefile with a Code::Blocks wrapper.

Mac OS X

Initial setup

First of all, clone OpenMW repo.

$ git clone github.com/zinnschlag/openmw

Or use your github url if you forked.

About dependencies: I prefer not to install them globally (i. e. in /usr/local/), so I'm installing them in directory in my home directory. If OpenMW sources is in $HOME/path/openmw, I'm using $HOME/path/libs/root as prefix for boost and other libs.

It's useful to create env var for lib install prefix:

$ export OMW_LIB_PREFIX=$HOME/path/libs/root

Most of libs can be installed from Homebrew. Only mpg123 needs to be installed from source (due to lack of universal compilation support). I think that some of libs can be installed from MacPorts or Fink too.

As OpenMW currently only supports i386 architecture on OS X, denendencies also should support it. Set some env vars in current terminal:

$ export CFLAGS="-arch i386"
$ export CXXFLAGS="-arch i386"
$ export LDFLAGS="-arch i386"

If you close your terminal, you should set env vars again before pcoceeding to next steps!

Boost

Download boost and install it with the following command:

$ cd /path/to/boost/source
$ ./bootstrap.sh --prefix=$OMW_LIB_PREFIX
$ ./bjam --build-dir=build --layout=versioned \
    --toolset=darwin architecture=x86 address-model=32 \
    --link-shared,static --prefix=$OMW_LIB_PREFIX install

Alternatively you can install boost with homebrew:

$ brew install boost --universal

I think MacPorts also should support universal build for boost.

Ogre

Download Ogre SDK (tested with 1.7.3), unpack it somewhere and move lib/Release/Ogre.framework into /Library/Frameworks.

OIS

Download patched OIS and use the XCode project provided. Be sure to set your build architecture to i386. Once it built, locate built OIS.framework with Xcode and move it to /Library/Frameworks.

mpg123

Download MPG 123 and build it:

$ cd /path/to/mpg123/source
$ ./configure --prefix=$OMW_LIB_PREFIX --disable-debug \
  --disable-dependency-tracking \
  --with-optimization=4 \
  --with-audio=dummy \
  --with-default-audio=dummy \
  --with-cpu=sse_alone \
$ make install

libsndfile

Download libsndfile and build it:

$ cd /path/to/libsndfile/source
$ ./configure --prefix=$OMW_LIB_PREFIX \
  --disable-dependency-tracking
$ make install

or install with homebrew:

$ brew install libsndfile --universal

Bullet

Download Bullet and build it:

$ cd /path/to/bullet/source
$ mkdir build
$ cd build
$ cmake -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_INSTALL_PREFIX=$OMW_LIB_PREFIX \
  -DBUILD_EXTRAS=OFF \
  -DBUILD_DEMOS=OFF \
  -DCMAKE_OSX_ARCHITECTURES=i386 \
  -DCMAKE_INSTALL_NAME_DIR=$OMW_LIB_RPEFIX/lib \
  -G"Unix Makefiles" ../
$ make install

or install with homebrew:

$ brew install bullet --HEAD --universal

I prefer head because 2.79 has some issue which causes OpenMW to lag. Also you can edit formula and install 2.77, which is stable and haven't mentioned issue.

Qt

Install Qt. Qt SDK distributed by Nokia is not an option because it's 64 bit only, and OpenMW currently doesn't build for 64 bit on OS X. I'm installing it from Homebrew:

$ brew install qt --universal

Run CMake

Generate the Makefile for OpenMW as follows and build OpenMW:

$ mkdir /path/to/openmw/build/dir
$ cd /path/to/open/build/dir
$ cmake \
  -D CMAKE_OSX_ARCHITECTURES=i386 \
  -D OGRE_SDK=/path/to/ogre/sdk \
  -D BOOST_INCLUDEDIR=$OMW_LIB_PREFIX/include/boost-1_45 \
  -D BOOST_LIBRARYDIR=$OMW_LIB_PREFIX/lib \
  -D SNDFILE_INCLUDE_DIR=$OMW_LIB_PREFIX/include \
  -D SNDFILE_LIBRARY=$OMW_LIB_PREFIX/lib/libsndfile.a \
  -D MPG123_LIBRARY=$OMW_LIB_PREFIX/lib/libmpg123.a \
  -D MPG123_INCLUDE_DIR=$OMW_LIB_PREFIX/include \
  -D BULLET_DYNAMICS_LIBRARY=$OMW_LIB_PREFIX/lib/libBulletDynamics.a \
  -D BULLET_COLLISION_LIBRARY=$OMW_LIB_PREFIX/lib/libBulletCollision.a \
  -D BULLET_MATH_LIBRARY=$OMW_LIB_PREFIX/lib/libLinearMath.a \
  -D BULLET_SOFTBODY_LIBRARY=$OMW_LIB_PREFIX/lib/libBulletSoftBody.a \
  -D BULLET_INCLUDE_DIR=$OMW_LIB_PREFIX/include/bullet/ \
  -G "Unix Makefiles" /path/to/openmw/source/dir
$ make

You can use -G"Xcode" if you prefer Xcode, or -G"Eclipse CDT4 - Unix Makefiles" if you prefer Eclipse. You also can specify -D CMAKE_BUILD_TYPE=Debug for debug build. As for CMake 2.8.7 and Xcode 4.3, Xcode generator is broken. Sadly Eclipse CDT also cannot import generated project at least on my machine.

If all libs installed via homebrew (excluding mpg123), then command would be even simplier:

$ cmake \
  -D CMAKE_OSX_ARCHITECTURES=&quot;i386&quot; \
  -D OGRE_SDK=/path/to/ogre/sdk \
  -D MPG123_LIBRARY=$OMW_LIB_PREFIX/lib/libmpg123.a \
  -D MPG123_INCLUDE_DIR=$OMW_LIB_PREFIX/include \
  -G "Unix Makefiles" /path/to/openmw/source/dir
$ make

Note for users with recent Xcode versions: you must explicitly specify what set of compilers do you use! If not, gcc will be used for C and Clang for C++. Just add this two -D's to command: -D CMAKE_C_COMPILER=/usr/bin/clang and -D CMAKE_CXX_COMPILER=/usr/bin/clang

Note for Xcode 4.3 users: you should specify full path to used SDK, because current CMake (2.8.7) couldn't find SDKs inside Xcode app bundle:

-D CMAKE_OSX_SYSROOT="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk"

Run

From your build directory run:

$ OpenMW.app/Contents/MacOS/openmw

or:

$ open OpenMW.app

Enjoy!

Data

You can use unshield to extract data from your Morrowind CD.

Datafiles are inside data1.cab and data2.cab. You just need to copy thoses files to you data folder :

* Sound
* Music
* Video
* Splash
* Morrowind.esm
* Morrowind.bsa

Edit your openmw.cfg file, and you are ready !