Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/libraries/core/DynLib.cc @ 8590

Last change on this file since 8590 was 8351, checked in by rgrieder, 14 years ago

Merged kicklib2 branch back to trunk (includes former branches ois_update, mac_osx and kicklib).

Notes for updating

Linux:
You don't need an extra package for CEGUILua and Tolua, it's already shipped with CEGUI.
However you do need to make sure that the OgreRenderer is installed too with CEGUI 0.7 (may be a separate package).
Also, Orxonox now recognises if you install the CgProgramManager (a separate package available on newer Ubuntu on Debian systems).

Windows:
Download the new dependency packages versioned 6.0 and use these. If you have problems with that or if you don't like the in game console problem mentioned below, you can download the new 4.3 version of the packages (only available for Visual Studio 2005/2008).

Key new features:

  • *Support for Mac OS X*
  • Visual Studio 2010 support
  • Bullet library update to 2.77
  • OIS library update to 1.3
  • Support for CEGUI 0.7 —> Support for Arch Linux and even SuSE
  • Improved install target
  • Compiles now with GCC 4.6
  • Ogre Cg Shader plugin activated for Linux if available
  • And of course lots of bug fixes

There are also some regressions:

  • No support for CEGUI 0.5, Ogre 1.4 and boost 1.35 - 1.39 any more
  • In game console is not working in main menu for CEGUI 0.7
  • Tolua (just the C lib, not the application) and CEGUILua libraries are no longer in our repository. —> You will need to get these as well when compiling Orxonox
  • And of course lots of new bugs we don't yet know about
  • Property svn:eol-style set to native
File size: 4.6 KB
Line 
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4    (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2006 Torus Knot Software Ltd
8Also see acknowledgements in Readme.html
9
10This program is free software; you can redistribute it and/or modify it under
11the terms of the GNU Lesser General Public License as published by the Free Software
12Foundation; either version 2 of the License, or (at your option) any later
13version.
14
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18
19You should have received a copy of the GNU Lesser General Public License along with
20this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21Place - Suite 330, Boston, MA 02111-1307, USA, or go to
22http://www.gnu.org/copyleft/lesser.txt.
23
24You may alternatively use this source under the terms of a specific version of
25the OGRE Unrestricted License provided you have obtained such a license from
26Torus Knot Software Ltd.
27-----------------------------------------------------------------------------
28*/
29
30// 08/11/2009: Small adjustments for Orxonox by Fabian 'x3n' Landau
31
32#include "DynLib.h"
33
34#include "util/Exception.h"
35
36#ifdef ORXONOX_PLATFORM_WINDOWS
37#  define WIN32_LEAN_AND_MEAN
38#  ifndef NOMINMAX
39#    define NOMINMAX // required to stop windows.h messing up std::min
40#  endif
41#  include <windows.h>
42#endif
43
44#ifdef ORXONOX_PLATFORM_UNIX
45#  include <dlfcn.h>
46#endif
47
48#ifdef ORXONOX_PLATFORM_APPLE
49#   include <OSX/macUtils.h> // OGRE include
50#endif
51
52namespace orxonox
53{
54    //-----------------------------------------------------------------------
55    DynLib::DynLib( const std::string& name )
56    {
57        mName = name;
58        m_hInst = NULL;
59    }
60
61    //-----------------------------------------------------------------------
62    DynLib::~DynLib()
63    {
64    }
65
66    //-----------------------------------------------------------------------
67    void DynLib::load()
68    {
69        // Log library load
70        COUT(2) << "Loading module " << mName << std::endl;
71
72        std::string name = mName;
73#ifdef ORXONOX_PLATFORM_LINUX
74        // dlopen() does not add .so to the filename, like windows does for .dll
75        if (name.substr(name.length() - 3, 3) != ".so")
76           name += ".so";
77#elif defined(ORXONOX_PLATFORM_APPLE)
78        // dlopen() does not add .dylib to the filename, like windows does for .dll
79        if (name.substr(name.length() - 6, 6) != ".dylib")
80            name += ".dylib";
81#elif defined(ORXONOX_PLATFORM_WINDOWS)
82        // Although LoadLibraryEx will add .dll itself when you only specify the library name,
83        // if you include a relative path then it does not. So, add it to be sure.
84        if (name.substr(name.length() - 4, 4) != ".dll")
85            name += ".dll";
86#endif
87
88        m_hInst = (DYNLIB_HANDLE)DYNLIB_LOAD( name.c_str() );
89
90        if (!m_hInst)
91            ThrowException(
92                General,
93                "Could not load dynamic library " + mName +
94                ".  System Error: " + dynlibError());
95    }
96
97    //-----------------------------------------------------------------------
98    void DynLib::unload()
99    {
100        // Log library unload
101        COUT(4) << "Unloading module " << mName << std::endl;
102
103        if (DYNLIB_UNLOAD( m_hInst ))
104        {
105            ThrowException(
106                General,
107                "Could not unload dynamic library " + mName +
108                ".  System Error: " + dynlibError());
109        }
110
111    }
112
113    //-----------------------------------------------------------------------
114    void* DynLib::getSymbol( const std::string& strName ) const throw()
115    {
116        return (void*)DYNLIB_GETSYM( m_hInst, strName.c_str() );
117    }
118    //-----------------------------------------------------------------------
119    std::string DynLib::dynlibError( void )
120    {
121#if defined(ORXONOX_PLATFORM_WINDOWS)
122        LPVOID lpMsgBuf;
123        FormatMessage(
124            FORMAT_MESSAGE_ALLOCATE_BUFFER |
125            FORMAT_MESSAGE_FROM_SYSTEM |
126            FORMAT_MESSAGE_IGNORE_INSERTS,
127            NULL,
128            GetLastError(),
129            MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
130            (LPTSTR) &lpMsgBuf,
131            0,
132            NULL
133            );
134        std::string ret = (char*)lpMsgBuf;
135        // Free the buffer.
136        LocalFree( lpMsgBuf );
137        return ret;
138#elif defined(ORXONOX_PLATFORM_UNIX)
139        return std::string(dlerror());
140#else
141        return "";
142#endif
143    }
144}
Note: See TracBrowser for help on using the repository browser.