Index: code/branches/libraries/src/orxonox/CMakeLists.txt
===================================================================
--- code/branches/libraries/src/orxonox/CMakeLists.txt	(revision 5612)
+++ code/branches/libraries/src/orxonox/CMakeLists.txt	(revision 5613)
@@ -37,5 +37,5 @@
 ENDIF()
 
-ORXONOX_ADD_EXECUTABLE(orxonox
+ORXONOX_ADD_LIBRARY(orxonox
   FIND_HEADER_FILES
   TOLUA_FILES
@@ -45,8 +45,8 @@
     objects/quest/QuestDescription.h
     objects/quest/QuestManager.h
+  DEFINE_SYMBOL
+    "ORXONOX_SHARED_BUILD"
   PCH_FILE
     OrxonoxPrecompiledHeaders.h
-  # When defined as WIN32 this removes the console window on Windows
-  ${ORXONOX_WIN32}
   LINK_LIBRARIES
     ${Boost_FILESYSTEM_LIBRARY}
@@ -69,5 +69,16 @@
 )
 
-GET_TARGET_PROPERTY(_exec_loc orxonox LOCATION)
+ORXONOX_ADD_EXECUTABLE(orxonox-main
+  FIND_HEADER_FILES
+  # When defined as WIN32 this removes the console window on Windows
+  ${ORXONOX_WIN32}
+  LINK_LIBRARIES
+    orxonox
+  SOURCE_FILES
+    Orxonox.cc
+  OUTPUT_NAME orxonox
+)
+
+GET_TARGET_PROPERTY(_exec_loc orxonox-main LOCATION)
 GET_FILENAME_COMPONENT(_exec_name ${_exec_loc} NAME)
 SET(ORXONOX_EXECUTABLE_NAME ${_exec_name} CACHE INTERNAL "")
Index: code/branches/libraries/src/orxonox/Main.cc
===================================================================
--- code/branches/libraries/src/orxonox/Main.cc	(revision 5612)
+++ code/branches/libraries/src/orxonox/Main.cc	(revision 5613)
@@ -27,9 +27,9 @@
  *
  */
- 
+
 /**
 @file
 @brief
-    Entry point of the program.
+    The main function of Orxonox.
 */
 
@@ -37,15 +37,8 @@
 #include "SpecialConfig.h"
 
-#ifdef ORXONOX_USE_WINMAIN
-# ifndef WIN32_LEAN_AND_MEAN
-#  define WIN32_LEAN_AND_MEAN
-# endif
-#include <windows.h>
-#endif
-
-#include "util/Debug.h"
 #include "util/Exception.h"
 #include "core/CommandLine.h"
 #include "core/Game.h"
+#include "Main.h"
 
 SetCommandLineSwitch(console).information("Start in console mode (text IO only)");
@@ -56,25 +49,13 @@
 SetCommandLineSwitch(standalone).information("Start in standalone mode");
 
-/*
-@brief
-    Main method. Game starts here (except for static initialisations).
-*/
-#ifdef ORXONOX_USE_WINMAIN
-INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT)
-#else
-int main(int argc, char** argv)
-#endif
+namespace orxonox
 {
-    using namespace orxonox;
-
-    Game* game = 0;
-    try
+    /**
+    @brief
+        Main method. Game starts here (except for static initialisations).
+    */
+    int main(const std::string& strCmdLine)
     {
-#ifndef ORXONOX_USE_WINMAIN
-        std::string strCmdLine;
-        for (int i = 1; i < argc; ++i)
-            strCmdLine += argv[i] + std::string(" ");
-#endif
-        game = new Game(strCmdLine);
+        Game* game = new Game(strCmdLine);
 
         game->setStateHierarchy(
@@ -108,21 +89,9 @@
         else
             Game::getInstance().requestStates("graphics, mainMenu");
+
+        game->run();
+        delete game;
+
+        return 0;
     }
-    catch (const std::exception& ex)
-    {
-        COUT(0) << "Orxonox failed to initialise: " << ex.what() << std::endl;
-        COUT(0) << "Terminating program." << std::endl;
-        return 1;
-    }
-    catch (...)
-    {
-        COUT(0) << "Orxonox failed to initialise: " << std::endl;
-        COUT(0) << "Terminating program." << std::endl;
-        return 1;
-    }
-
-    game->run();
-    delete game;
-
-    return 0;
 }
Index: code/branches/libraries/src/orxonox/Main.h
===================================================================
--- code/branches/libraries/src/orxonox/Main.h	(revision 5613)
+++ code/branches/libraries/src/orxonox/Main.h	(revision 5613)
@@ -0,0 +1,40 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Main_H__
+#define _Main_H__
+
+#include "OrxonoxPrereqs.h"
+
+namespace orxonox
+{
+    _OrxonoxExport int main(const std::string& strCmdLine);
+}
+
+#endif /* _Main_H__ */
Index: code/branches/libraries/src/orxonox/Orxonox.cc
===================================================================
--- code/branches/libraries/src/orxonox/Orxonox.cc	(revision 5613)
+++ code/branches/libraries/src/orxonox/Orxonox.cc	(revision 5613)
@@ -0,0 +1,81 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+@file
+@brief
+    Entry point of the program.
+*/
+
+#include "OrxonoxPrereqs.h"
+#include "SpecialConfig.h"
+
+#ifdef ORXONOX_USE_WINMAIN
+# ifndef WIN32_LEAN_AND_MEAN
+#  define WIN32_LEAN_AND_MEAN
+# endif
+#include <windows.h>
+#endif
+
+#include "util/Debug.h"
+#include "Main.h"
+
+/*
+@brief
+    Main method. Game starts here (except for static initialisations).
+*/
+#ifdef ORXONOX_USE_WINMAIN
+INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT)
+#else
+int main(int argc, char** argv)
+#endif
+{
+    try
+    {
+#ifndef ORXONOX_USE_WINMAIN
+        std::string strCmdLine;
+        for (int i = 1; i < argc; ++i)
+            strCmdLine += argv[i] + std::string(" ");
+
+        return orxonox::main(strCmdLine);
+#endif
+    }
+    catch (const std::exception& ex)
+    {
+        COUT(0) << "Orxonox failed to initialise: " << ex.what() << std::endl;
+        COUT(0) << "Terminating program." << std::endl;
+        return 1;
+    }
+    catch (...)
+    {
+        COUT(0) << "Orxonox failed to initialise: " << std::endl;
+        COUT(0) << "Terminating program." << std::endl;
+        return 1;
+    }
+}
Index: code/branches/libraries/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- code/branches/libraries/src/orxonox/OrxonoxPrereqs.h	(revision 5612)
+++ code/branches/libraries/src/orxonox/OrxonoxPrereqs.h	(revision 5613)
@@ -40,6 +40,5 @@
 // Shared library settings
 //-----------------------------------------------------------------------
-#define ORXONOX_NO_EXPORTS // This is an executable that needs no exports
-#if defined(ORXONOX_PLATFORM_WINDOWS) && !(defined(ORXONOX_STATIC_BUILD) || defined(ORXONOX_NO_EXPORTS))
+#if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(ORXONOX_STATIC_BUILD)
 #  ifdef ORXONOX_SHARED_BUILD
 #    define _OrxonoxExport __declspec(dllexport)
