Development:Compiling: Difference between revisions

From Adonthell
Jump to navigation Jump to search
Shirish (talk | contribs)
Shirish (talk | contribs)
m GNU Autotools: minor additions ~~~~
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
After having installed all of Adonthell's [[Development:Dependency Matrix|Dependencies]] and obtained the source code from [[Development:GIT|Git]] you can finally compile it. Please follow the general instructions and see the hints specific to your OS if you get stuck. Refer to the instructions included with the source code for further details.
After having installed all of Adonthell's [[Development:Dependency Matrix|Dependencies]] and obtained the source code from [[Development:GIT|Git]] you can finally compile it. Please follow the build instructions and see the known issues and hints specific to your OS if you get stuck. For further details, refer to the instructions included with the source code.


== General Instructions ==
== Engine Build Instructions ==


For all Systems, we assume a POSIX-like environment with GNU compiler and make and a shell. Where supported, you should use the CMake based build system, but we'll probably keep the GNU autotools around for some while too. In both cases, an out-of-source build is recommended.
For all Systems, we assume a POSIX-like environment with GNU compiler and make and a shell. Where supported, you should use the CMake based build system, but we'll probably keep the GNU autotools around for some while too. In both cases, an out-of-source build is recommended.


=== Building dependencies ===
=== CMake ===
[http://code.google.com/p/google-glog/ google-glog], [http://code.google.com/p/googletest/ googletest], and [http://code.google.com/p/googlemock/ googlemock] require special preparation, as only googletest seems to be currently packed for Ubuntu, and the packaged version is well out of date.
 
==== google-glog ====
# Get the source: <pre>wget http://google-glog.googlecode.com/files/glog-0.3.0.tar.gz</pre>
# Unpack the source: <pre>tar xvzf glog-0.3.0.tar.gz</pre>
# Build and install: <pre>cd glog-0.3.0&#13;./configure && make && sudo make install</pre>
 
==== googletest ====
# Get the source: <pre>wget http://googletest.googlecode.com/files/gtest-1.4.0.tar.gz</pre>
# Unpack the source: <pre>tar xvzf gtest-1.4.0.tar.gz</pre>
# Get the patch: <pre>wget http://www.jmglov.net/opensource/src/gtest-1.4.0_pkg-config.patch</pre>
# Patch the source: <pre>patch -p0 <gtest-1.4.0_pkg-config.patch</pre>
# Build and install: <pre>cd gtest-0.4.0&#13;./configure && make && sudo make install</pre>
 
==== googlemock ====
# Get the source: <pre>wget http://googlemock.googlecode.com/files/gmock-1.4.0.tar.gz</pre>
# Unpack the source: <pre>tar xvzf gmock-1.4.0.tar.gz</pre>
# Get the patch: <pre>wget http://www.jmglov.net/opensource/src/gmock-1.4.0_pkg-config.patch</pre>
# Patch the source: <pre>patch -p0 <gmock-1.4.0_pkg-config.patch</pre>
# Build and install: <pre>cd gmock-0.4.0&#13;./configure && make && sudo make install</pre>
 
=== CMake based build ===


Inside the ''adonthell'' directory type:
Inside the ''adonthell'' directory type:
Line 36: Line 14:
   sudo make install
   sudo make install


'''Beware:''' with cmake prior to version 2.6 you should remove old versions of the Adonthell 0.4 libraries before the build.
Including the optional <tt>-DDEVBUILD=1</tt> parameter will enable a developer build, which gives you unit tests and debug symbols but requires [[Development:Developer Build|additional dependencies]]; if you are compiling Adonthell as an end user, you probably won't want to turn this on.


The -DDEVBUILD=1 enables a developer build, which gives you unit tests and debug symbols; if you are compiling Adonthell as an end user, you probably won't want to turn this on.
=== GNU Autotools ===
 
=== GNU Autotools based build ===


Inside the ''adonthell'' directory type:
Inside the ''adonthell'' directory type:
Line 48: Line 24:
   ../adonthell/configure --enable-dev-build --prefix=/usr/local
   ../adonthell/configure --enable-dev-build --prefix=/usr/local
   make
   make
   sudo make install
   * $ sudo DESTDIR=$PATH make install


The --enable-devbuild enables a developer build, which gives you unit tests and debug symbols; if you are compiling Adonthell as an end user, you probably won't want to turn this on.
*Note :- There is an issue/bug/regression in automake 1.11 due to which automake does not honor the 'sudo make install' command and you have to explicitly state the same as shown above. This has been discussed in the [http://lists.nongnu.org/archive/html/adonthell-general/2012-07/msg00010.html mailing list] as well. As and when the bug is fixed and automake gets the older behavior back this note will disappear.  


=== GNU Autotools build for Adonthell-tools ===
Including the optional <tt>--enable-devbuild</tt> parameter will enable a developer build, which gives you unit tests and debug symbols but requires [[Development:Developer Build|additional dependencies]]; if you are compiling Adonthell as an end user, you probably won't want to turn this on.


There is another directory called adonthell-tools. It also functions the same way.
=== Customizing the Installation ===


  ./autogen.sh
Due to the modular structure of the Adonthell Engine, it needs to be properly installed on the system before it is ready to use. The recommended location for that is /usr/local, but if you don't want to pollute your system or don't have root privileges, you can chose any other location. Below you will find the steps required to make it work:
/somepath/adonthell-tools/$ mkdir ../adonthell-tools-build && cd ../adonthell-build
/somepath/adonthell-tools-build/$ ../adonthell-tools/configure --enable-dev-build --prefix=/usr/local
  make
  sudo make install
 
=== Installing in custom directory ===
 
If you'd like to change the default installation directory (for example to be able to install without root privileges), it's possible to specify a different one when invoking cmake or configure. It's important to add the directory, where the adonthell python modules are installed, to [http://docs.python.org/using/cmdline.html#envvar-PYTHONPATH PYTHONPATH].


==== CMake ====
==== CMake ====


There two commandline options that control the installation path are:
There two commandline options that control the installation path are:
# '''-DCMAKE_INSTALL_PREFIX=/path/to/adonthell''': controls, where the adonthell libraries and headers are installed.
# '''-DCMAKE_INSTALL_PREFIX=/path/to/adonthell''': controls where the adonthell libraries and headers are installed.
# '''-DPYTHON_SITE_PACKAGE_DIR=/path/to/python/modules''': controls, where python bindings for adonthell are installed. The same path as specified here should be appended to PYTHONPATH.
# '''-DPYTHON_SITE_PACKAGE_DIR=/path/to/py-modules''': controls where python bindings for adonthell are installed.


==== GNU Autotools ====
==== GNU Autotools ====
Line 76: Line 44:
The installation path is defined using the '''--prefix=/path/to/adonthell''' option.
The installation path is defined using the '''--prefix=/path/to/adonthell''' option.


'''Note:''' Its advisable to add the variables where you are installing adonthell in your $PATH if its in a non-standard location as well as PKG_CONFIG_PATH to tell where the libraries are.
==== Preparing the Environment ====


Finding default PATH environment variables on GNU/Linux :- One can find the default PATH by doing :-
After installing to a custom location, the environment needs to be prepared in order to use the Adonthell engine. This is done by updating the following environment variables
      $echo $PATH


On a reasonably clean system it should give something like this:-
# '''PATH''': controls where the system looks for executables
    $echo $PATH
# '''PYTHONPATH''': controls where Python looks for additional modules
    $/usr/local/bin:/usr/bin:/bin:
# '''PKG_CONFIG_PATH''': controls where pkg-config looks for package information (only if you intend to compile the Adonthell tools as well).
Now one can add adonthell to the path by pushing it to your .bashrc. .bashrc to put simply has each user's commands, the way (s)he likes her command prompt and many such things. To add it, simply write the following on the CLI (Command-Line Interface) or/and bash prompt.  


    $echo 'export PATH="$PATH:$HOME/somepath/adonthell"' >> ~shirish/.bashrc
Assuming that you specified '''$HOME/local/adonthell''' as prefix (and '''$HOME/local/py-modules''' for python packages) you would set the variables as follows:


Similarly you need to also add an environment variable called 'PKG_CONFIG_PATH' which you can either call from the CLI each time or add it to your .bashrc one time as well. On a bare/clean system you will see nothing.
    $ export PATH=$PATH:$HOME/local/adonthell/bin
    $ export PYTHONPATH=$PYTHONPATH:$HOME/local/py-modules
    $ export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/local/adonthell/lib/pkgconfig


    $echo $PKG_CONFIG_PATH
You can add those lines to the end of your $HOME/.bashrc file if you don't want to type them in everytime you open a new shell (assuming that you are indeed using a bash-like shell).
   
    $


This means there was no output. Now you can add it as same as we did for path, the only difference is the environment variable and the location of pkg_config. As said before this can be known ONLY after adonthell has been installed.
=== Testing the Installation ===


    $echo 'export PKG_CONFIG_PATH="$PATH:$HOME/somepath/adonthell/lib/pkgconfig"' >> ~shirish/.bashrc
After Adonthell has been compiled and installed successfully, you can verify that everything works as expected by running one of the test programs found in the test directory within adonthell-build:


Each variable entered starts to function in a new terminal instance.So start a new terminal instance and see each of them.  
  adonthell-build$ cd test/
  adonthell-build/test/$ ./worldtest -g ../../adonthell/test data


  $echo $PKG_CONFIG_PATH
This should bring up a small map with some structures to climb and jump and a NPC to talk to.
  :/home/shirish/games/adonthell/lib/pkgconfig
  $


This means things are correctly defined there.
== Tools Build Instructions ==


=== Running Adonthell ===
Now that you have a working Adonthell installation on your system, you are ready to build the [[Tools:Contents|Adonthell Tools]], if you so desire, by following [[Tools:Installation|these instructions]].
After compiling adonthell go to the test directory within adonthell-build


  /somepath/adonthell-build$cd test
== OS Specifc Notes ==
  /somepath/adonthell-build/test/$  ./worldtest -g ../../adonthell/test data


Also run this one :-
=== GNU/Linux or *BSD ===
 
  /somepath/adonthell-build/test/$ ./worldtest -g ../.. wastesedge
 
Somepath denotes here an arbitary location chosen by the user. Some arbitary static location on the hard disk where the user wants to put all the adonthell directories.
 
=== Running Adonthell-tools ===
After compiling adonthell-tools you have to go to the sub-directory /adonthell-tools-build/src/mapedit and type :-
 
    /somepath/adonthell/adonthell-tools-build/src/mapedit$ ./adonthell-mapedit -g ../../../ -p wastesedge ../../../wastesedge/redwyne-inn.xml
 
Each tool would have its own directory you need to go in there and use it. For instance, here's how to run the modeller :-
 
  /somepath/adonthell-tools-build/src/modeller$ ./adonthell-modeller -g
../../../ -p wastesedge ../../../wastesedge/redwyne-inn.xml
 
 
And similar for the dialogue-editor :-
 
  /adonthell-tools-build/src/dlgedit$ ./adonthell-dlgedit -g ../../../ -p wastesedge ../../../wastesedge/redwyne-inn.xml
 
and so on and so forth. If you make a file with each program they would each have a specific extension which is read/understood by the program.
 
== Developing on GNU/Linux or *BSD ==


Most, if not all, dependencies should come with your distribution. Just make sure to install the corresponding development packages. In case that you require a newer version of a library or tool than comes with the distribution, you should be able to compile and install it yourself without much trouble.
Most, if not all, dependencies should come with your distribution. Just make sure to install the corresponding development packages. In case that you require a newer version of a library or tool than comes with the distribution, you should be able to compile and install it yourself without much trouble.
Line 142: Line 81:
In general, you should be able to use any IDE of your choice as long as it is not messing with the Makefiles. If you have a particular good setup, feel free to share the instructions.
In general, you should be able to use any IDE of your choice as long as it is not messing with the Makefiles. If you have a particular good setup, feel free to share the instructions.


== Developing on MacOS X ==
=== MacOS X ===


Like on Linux, you can get most of the dependencies in the form of precompiled binaries, e.g. from the [http://finkproject.org Fink Project]. If you need an IDE, use [[Development:IDE:XCode|XCode]].
Like on Linux, you can get most of the dependencies in the form of precompiled binaries, e.g. from the [http://finkproject.org Fink Project]. If you need an IDE, use [[Development:IDE:XCode|XCode]].


''Most likely I will buy a new Mac once Leopard is released. Then I'll document all the required steps to get an Adonthell development environment going. (Kai)''
=== Windows ===
 
== Developing on Windows ==


Since Adonthell requires the GNU Compiler Collection (GCC), your best choices are either [http://www.cygwin.com Cygwin] or [http://www.mingw.org MinGW]. In order to produce "''true''" Windows binaries that do not depend on the Cygwin POSIX layer (cygwin1.dll), setting up a development environment with [[Development:MSYS/MinGW|MSYS/MinGW]] is recommended. A good IDE to use would be [[Development:IDE:Eclipse|Eclipse]], which is becoming supported directly by [http://www.cmake.org/Wiki/Eclipse_CDT4_Generator CMake].
Since Adonthell requires the GNU Compiler Collection (GCC), your best choices are either [http://www.cygwin.com Cygwin] or [http://www.mingw.org MinGW]. In order to produce "''true''" Windows binaries that do not depend on the Cygwin POSIX layer (cygwin1.dll), setting up a development environment with [[Development:MSYS/MinGW|MSYS/MinGW]] is recommended. A good IDE to use would be [[Development:IDE:Eclipse|Eclipse]], which is becoming supported directly by [http://www.cmake.org/Wiki/Eclipse_CDT4_Generator CMake].


== Developing on other OS ==
=== Other OS ===


Sorry, right now you are on your own. But if your system has a recent port of GCC and is supported by SDL, chances are pretty good that you will get Adonthell working. Please update this space if you did :-).
Sorry, right now you are on your own. But if your system has a recent port of GCC and is supported by SDL, chances are pretty good that you will get Adonthell working. Please update this space if you did :-).


== Fixing problems ==
== Known Problems ==


=== ImportError: No module named adonthell.world ===
=== ImportError: No module named adonthell.world ===
Line 172: Line 109:


The only workaround for that is removing any superfluous Python installations, then running cmake again.   
The only workaround for that is removing any superfluous Python installations, then running cmake again.   
=== debug.py not found ===
In case you get the error while <tt>make install</tt>, that a <tt>debug.py</tt> file cannot be found, simply
echo crap > ../adonthell/src/py-wrappers/runtime/debug.py


[[Category:Development]]
[[Category:Development]]

Latest revision as of 16:17, 4 September 2012

After having installed all of Adonthell's Dependencies and obtained the source code from Git you can finally compile it. Please follow the build instructions and see the known issues and hints specific to your OS if you get stuck. For further details, refer to the instructions included with the source code.

Engine Build Instructions

For all Systems, we assume a POSIX-like environment with GNU compiler and make and a shell. Where supported, you should use the CMake based build system, but we'll probably keep the GNU autotools around for some while too. In both cases, an out-of-source build is recommended.

CMake

Inside the adonthell directory type:

 mkdir ../adonthell-build && cd ../adonthell-build
 cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DDEVBUILD=1 ../adonthell
 make
 sudo make install

Including the optional -DDEVBUILD=1 parameter will enable a developer build, which gives you unit tests and debug symbols but requires additional dependencies; if you are compiling Adonthell as an end user, you probably won't want to turn this on.

GNU Autotools

Inside the adonthell directory type:

 ./autogen.sh
 mkdir ../adonthell-build && cd ../adonthell-build
 ../adonthell/configure --enable-dev-build --prefix=/usr/local
 make
 * $ sudo DESTDIR=$PATH make install
  • Note :- There is an issue/bug/regression in automake 1.11 due to which automake does not honor the 'sudo make install' command and you have to explicitly state the same as shown above. This has been discussed in the mailing list as well. As and when the bug is fixed and automake gets the older behavior back this note will disappear.

Including the optional --enable-devbuild parameter will enable a developer build, which gives you unit tests and debug symbols but requires additional dependencies; if you are compiling Adonthell as an end user, you probably won't want to turn this on.

Customizing the Installation

Due to the modular structure of the Adonthell Engine, it needs to be properly installed on the system before it is ready to use. The recommended location for that is /usr/local, but if you don't want to pollute your system or don't have root privileges, you can chose any other location. Below you will find the steps required to make it work:

CMake

There two commandline options that control the installation path are:

  1. -DCMAKE_INSTALL_PREFIX=/path/to/adonthell: controls where the adonthell libraries and headers are installed.
  2. -DPYTHON_SITE_PACKAGE_DIR=/path/to/py-modules: controls where python bindings for adonthell are installed.

GNU Autotools

The installation path is defined using the --prefix=/path/to/adonthell option.

Preparing the Environment

After installing to a custom location, the environment needs to be prepared in order to use the Adonthell engine. This is done by updating the following environment variables

  1. PATH: controls where the system looks for executables
  2. PYTHONPATH: controls where Python looks for additional modules
  3. PKG_CONFIG_PATH: controls where pkg-config looks for package information (only if you intend to compile the Adonthell tools as well).

Assuming that you specified $HOME/local/adonthell as prefix (and $HOME/local/py-modules for python packages) you would set the variables as follows:

   $ export PATH=$PATH:$HOME/local/adonthell/bin
   $ export PYTHONPATH=$PYTHONPATH:$HOME/local/py-modules
   $ export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/local/adonthell/lib/pkgconfig

You can add those lines to the end of your $HOME/.bashrc file if you don't want to type them in everytime you open a new shell (assuming that you are indeed using a bash-like shell).

Testing the Installation

After Adonthell has been compiled and installed successfully, you can verify that everything works as expected by running one of the test programs found in the test directory within adonthell-build:

 adonthell-build$ cd test/
 adonthell-build/test/$ ./worldtest -g ../../adonthell/test data

This should bring up a small map with some structures to climb and jump and a NPC to talk to.

Tools Build Instructions

Now that you have a working Adonthell installation on your system, you are ready to build the Adonthell Tools, if you so desire, by following these instructions.

OS Specifc Notes

GNU/Linux or *BSD

Most, if not all, dependencies should come with your distribution. Just make sure to install the corresponding development packages. In case that you require a newer version of a library or tool than comes with the distribution, you should be able to compile and install it yourself without much trouble.

In general, you should be able to use any IDE of your choice as long as it is not messing with the Makefiles. If you have a particular good setup, feel free to share the instructions.

MacOS X

Like on Linux, you can get most of the dependencies in the form of precompiled binaries, e.g. from the Fink Project. If you need an IDE, use XCode.

Windows

Since Adonthell requires the GNU Compiler Collection (GCC), your best choices are either Cygwin or MinGW. In order to produce "true" Windows binaries that do not depend on the Cygwin POSIX layer (cygwin1.dll), setting up a development environment with MSYS/MinGW is recommended. A good IDE to use would be Eclipse, which is becoming supported directly by CMake.

Other OS

Sorry, right now you are on your own. But if your system has a recent port of GCC and is supported by SDL, chances are pretty good that you will get Adonthell working. Please update this space if you did :-).

Known Problems

ImportError: No module named adonthell.world

In case you have multiple versions of Python installed, CMake can get confused. If, during the initial run of cmake you get a mix of versions like seen below, Adonthell will not work correctly.

 Found PythonLibs: /usr/lib/python2.4/config/libpython2.4.so
 -- Python has been found:
 -- CFLAGS : /usr/include/python2.4
 -- LDFLAGS: /usr/lib/python2.4/config/libpython2.4.so
 -- Found PythonInterp: /usr/bin/python2.5
 -- VERSION: python2.5
 -- LDEXTRA: -lm;-lpthread -ldl  -lutil
 -- SITEPKG: /usr/lib/python2.5/site-packages

The only workaround for that is removing any superfluous Python installations, then running cmake again.