Development Environment Setup: Difference between revisions

From OpenMW Wiki
Jump to navigation Jump to search
(→‎Key requirements: this is silly, do not post stuff without checking with the owners first)
Line 109: Line 109:
====Key requirements====
====Key requirements====
Because some dependencies of OpenMW are not in the Ubuntu repositories we made a development repository on Launchpad which provides packages for the missing dependencies.
Because some dependencies of OpenMW are not in the Ubuntu repositories we made a development repository on Launchpad which provides packages for the missing dependencies.
'''The PPA's Ogre dependencies are currently broken - if you use this PPA, make sure to install the 'nvidia-cg-toolkit' package manually.
'''


To be able to install these packages you need to add the openmw/build Launchpad PPA by running:
To be able to install these packages you need to add the openmw/build Launchpad PPA by running:
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
sudo add-apt-repository ppa:openmw/build
sudo add-apt-repository ppa:openmw/openmw
</syntaxhighlight>
</syntaxhighlight>



Revision as of 12:32, 17 January 2014

This page will describe how to set a dev env for several OSes.

You might also want to read the GitHub FAQ first.

Third-Party Libraries and Tools

  • OpenMW currently uses the following libraries:
    • OGRE 1.8 - the main graphic engine
    • SDL2 - input and windowing
    • MyGUI 3.2.0 - GUI toolkit
    • Bullet 2.80 - the physics engine
    • OpenAL or OpenAL soft - for sound playback
    • FFmpeg For sound decoding and BINK video playback. Alternatively, you could use Audiere or mpg123 for sound decoding, but videos won't work then.
  • 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/2012/2013

Tools

  • Visual Studio 2008/2010/2012/2013 - normal or free (C++) express versions.
  • CMake: CMake at least v2.8, but grab the latest stable release.
  • Git - Our version control software: Git at least v1.8.x, but grab the latest stable release.

Libraries

  • Ogre: Choose OGRE v1.9 SDK for your Visual Studio version. Environment variable OGRE_HOME.
  • Boost: The lib shipped with OGRE are old and shouldn't be used. Replace those with Boost v1.50.0 (or later) binaries and headers. Headers go to "OGRE_ROOT\boost\boost" and libs go to "OGRE_ROOT\boost\lib" . Environment variable BOOST_ROOT. Download the installer for your Visual Studio version.
  • Bullet Download and build bullet, and make sure the libraries are put into the <install_path\lib\Release> folder, strip the ending off (like _vs2010) and set the environment variables BULLET_ROOT <install_path>, and BULLET_INCLUDE_DIR <install_path\src> folder.
  • Freetype: Freetype2, and set the environment variable FREETYPE_DIR and MYGUI_DEPENDENCIES_DIR to the <install_path>
  • MyGUI: Download and build following compilation instructions and set the MYGUI_HOME environment variable. In vs90 or vs100, set the mygui.ogreplatform properties->c/c++->general->additional includes to have 'c:\BOOST_ROOT\' as well.
  • OpenAL: Download OpenAL11CoreSDK and set the environment variable OPENALDIR.
  • QT. Download the latest Qt4 version for your Visual Studio version and install the environment variable QTDIR. Example: qt-win-opensource-4.8.4-vs2010.exe
  • msinttypes Download and extract to your visual studio 'install_root\VC\include' directory and overwrite the files there. This will give you C99 compliant inttypes.
  • FFmpeg Download and extract the dev and exe of ffmpeg. The latest builds don't work. A known working version is commit 1eabd71, available in the "previous versions" links on that page. The environment variable is FFMPEG_HOME.
  • SDL2 Download and extract the SDL2 VS "Development Libraries". SDL2-devel-2.0.1-VC.zip Then set the SDL2_LIBRARY variable to the location of the SDL2.dll file.


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)

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"


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

Installing Dependencies

Arch

There is a development package available for OpenMW on the AUR. It can be found at [1].

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

Gentoo

Instructions broken - missing SDL2 and ffmpeg You have to emerge dev-games/ogre with useflags "boost freeimage opengl threads zip" and dev-games/mygui with useflag ogre. The mygui package might need to be unmasked, see Gentoo handbook and is available in portage since 2012-11-01.

Ubuntu

Key requirements

Because some dependencies of OpenMW are not in the Ubuntu repositories we made a development repository on Launchpad which provides packages for the missing dependencies.

To be able to install these packages you need to add the openmw/build Launchpad PPA by running:

sudo add-apt-repository ppa:openmw/openmw

and to make sure that the ppa will be used run:

sudo apt-get update

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 libopenal-dev libpng-dev libogre-1.8-dev \
 libsdl2-dev libqt4-dev uuid-dev libboost-filesystem-dev libboost-thread-dev \
 libboost-wave-dev libboost-chrono-dev libboost-program-options-dev \
 libboost-system-dev libav-tools libavcodec-dev libavformat-dev \
 libavdevice-dev libavutil-dev libswscale-dev libpostproc-dev \
 libbullet-dev libmygui-dev libunshield-dev libtinyxml-dev cmake build-essential

Fedora

Package Installations

First off, we will need to download all of the necessery development libraries from the main Fedora repositories:

Instructions broken - missing SDL2 and ffmpeg. libsndfile and libmpg123 can be removed.

yum install @development-tools

yum install cmake openal-soft-devel bullet-devel ogre-devel libblkid-devel boost-devel qt-devel libsndfile-devel \
    zziplib-devel freetype-devel libXaw-devel libXrandr-devel libXxf86vm-devel libGLU-devel freeimage-devel openexr-devel \
    glew-devel tinyxml-devel tbb cppunit-devel git

Next, we will need to enable the RPMFusion repositories on our system if it isn't already done so, per the instructions found here: [2]

Once the RPMFusion repositories (both free and non-free) have been installed, we will also need the following packages:

yum install libmpg123-devel

Fetching the source

Download the source from the main downloads page: [3], or get the latest git snapshot:

 mkdir OpenMW
 
 cd OpenMW
 git clone git://github.com/zinnschlag/openmw.git

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 ../

This creates a regular makefile.

Now we can start compiling. Normally you can just run

make

but if you have multiple cores, you can decrease 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.

With Kdevelop

Kdevelop4 is very nice, easy-to-use and modern IDE. After getting source, just open Kdevelop and click "Project -> Open/Import Project..." and show path to code (.../OpenMW/openmw). You will have to choose build folder.

For building click on button "Build Selection". For running click "Execute". Running first time "Launch Configurations" will pop up. You have to set executable file by selecting "openmw", clicking "+" and choosing "openmw/apps/openmw/openmw" as "Project Target".

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.8rc1), 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!

Eclipse

You have to use the C/C++ version of Eclipse, that you can download here

Git within Eclipse

If you want to use Eclipse as Git explorer:

  1. From the project explorer, right click, and select "Import..."
  2. Select "Git / Projects from Git"
  3. Click "Next"
  4. Select "Local"
  5. Click "Next"
  6. "Add..." / "Browse", and select openmw's directory
  7. Click "Next"
  8. Select "Use the new project wizard", and "Finish".

Import the project

Select "C/C++ / Makefile project with existing code" as project type. In "Existing code location", click browse, and again,select openmw's folder. Also select "Linux GCC" as toolchain, then click "Finish".

Now right-click on your project, and select "Properties". Go to "C/C++ build", uncheck "use default build command", and specify your command, like

make -j 4 -C ${ProjDirPath}../build

Now you should be able to build openmw.

Fix includes

To fix includes (Eclipse complaining about Ogre and Bullet), go to project properties, "C/C++ General", "Paths and symbols", select "GNU C++".

Click the "add" button to add the following paths :

/usr/include/OGRE

/usr/include/bullet

Run

To run it, create a new Run configuration. Select openmw as project, and click "search project" to find the executable (../build/openmw). Then go to the Arguments panel and uncheck "Use default" for working directory, and type in : "${workspace_loc:openmw}../build"

Apply, and you should now be able to run openmw !

Data

For a detailed description of how to obtain the data files check Getting_Data_Files_for_Linux_Install.