Jump to content
XCOMUFO & Xenocide

Cegui Python Troubles


Pi Masta

Recommended Posts

Ok, I mentioned this to reist, and probably confusingly as well. (Also doesn't help that this only affects Windows and he cannot test this himself) I think I found out why the dependencies are not compiling on my machine (and Xenocide with it). It is due to a little mundane addition to the 'CEGUIRefCounted.h' file, making its class 'export' to the DLL. They actually made this update in version 0.5 of CEGUI, however, it got overlooked when updating CEGUI in the dependencies until recently (revision 1499).

 

Let me explain what happens. The 'RefCounted' class is merely a template that seems to work as a shared pointer. Before it was just a normal class with the template argument. Our CEGUIPython uses this file and its template. (It is a useful utility class, but it should not specific to CEGUI or CEGUIPython). After the update it was given the 'CEGUIEXPORT' macro prefix which is defined in CEGUIBase.h:

/*************************************************************************
Dynamic Library import / export control conditional
(Define CEGUIBASE_EXPORTS to export symbols, else they are imported)
*************************************************************************/
#if defined( __WIN32__ ) || defined( _WIN32 )
#   ifdef CEGUIBASE_EXPORTS
#	   define CEGUIEXPORT __declspec(dllexport)
#   else
#	   define CEGUIEXPORT __declspec(dllimport)
#   endif
#	   define CEGUIPRIVATE
#else
#	   define CEGUIEXPORT
#	   define CEGUIPRIVATE
#endif

 

Nothing too big here, a lot of the classes in CEGUI use this macro to allow them to be imported when called outside of the project and exported when building CEGUI (CEGUIBase has CEGUIBASE_EXPORTS defined on the command line). I'm assuming that CEGUI added it to the RefCounted template so that we can access the other classes RefCounted methods.

 

However here is where the problem lies in. Take a look at CEGUIPythonFunctor.h (well the important parts for my point):

#include "CEGUIRefCOunted.h"

namespace CEGUI
{

class PythonWrapper
{
// code here
};

class PythonFunctor
{
// code, methods and stuff
private:
  RefCounted<PythonCallbackWrapper> pythonCallback;
};

} // namespace

 

Now then, since CEGUIBASE_EXPORTS isn't defined in our project (which it shouldnt), the macro CEGUIEXPORT gets replaced with __declspec(dllimport). So when the compiler goes to link the pythonCallback with CEGUI's RefCounted, it goes to the CEGUIBase_d.dll and tries to look up the code for RefCounted class (So that it can call it through the DLL).

 

See the problem? The DLL doesn't have this class, (RefCounted is in a header it's never compiled directly as it is a template). Furthermore the DLL has no idea what a PythonCallbackWrapper is, that is defined in our project.

 

Now, why hasn't this cropped up on anyone else yet?

  • This affects windows only, you can see from the macro's definition that if it is not compiled on Windows, it gets defined to nothing
  • I'm guessing that nobody using windows has rebuilt the Dependencies lately, they should get this error as well
  • Everything still works for the Windows users (remember when they rebuilt the dependencies for CEGUI at 0.5 release, RefCounted wasn't updated), so nobody has bothered to rebuild the dependencies
  • CEGUIPython is really the only Add-on for CEGUI AFAIK, I don't think anybody tries to use their RefCounted class like we are trying to.

I think the fix is obvious (well maybe). We need to either create our own 'RefCounted' class, or use a SharedPointer from boost (not sure on this). I sort of tried this on my machine but I got another error in in the wonderful generated pythonCEGUI.cpp file, where appearantly it uses the class too, and cannot find the it in the DLL.

 

Well, I'm really out of time right now, this was kinda rushed but I think you all need to know about it. As it stands now, I cannot get Xenocide to run on my machine, which obviously makes it difficult to develop for it :D

Link to comment
Share on other sites

I think the fix is obvious (well maybe). We need to either create our own 'RefCounted' class, or use a SharedPointer from boost (not sure on this). I sort of tried this on my machine but I got another error in in the wonderful generated pythonCEGUI.cpp file, where appearantly it uses the class too, and cannot find the it in the DLL.

 

Well, I'm really out of time right now, this was kinda rushed but I think you all need to know about it. As it stands now, I cannot get Xenocide to run on my machine, which obviously makes it difficult to develop for it :D

The correct fix is to remove the CEGUIEXPORT modifier from the class definition in \cegui\include\CEGUIRefCounted.h

 

As the RefCounted class is not in a DLL, it should not have a declspec modifier.

I've checked the updated code into Xenocide's SVN, and posted a note on the CEGUI forums, so the CEGUI team can fix it at their end as well.

Link to comment
Share on other sites

×
×
  • Create New...