Error initializing CEGUI

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

strangedays
Not too shy to talk
Not too shy to talk
Posts: 27
Joined: Fri Jun 06, 2008 15:25

Error initializing CEGUI

Postby strangedays » Thu Jul 01, 2010 11:48

I am using CEGUI with OpenGL renderer. Renderer has been successfully initialized, however I cannot initialize CEGUI::System.

Code: Select all

 CEGUI::System::create( CEGUI::OpenGLRenderer::create() );


Log output is the following:

Code: Select all

01/07/2010 12:44:13 (Std)    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
01/07/2010 12:44:13 (Std)    +                     Crazy Eddie's GUI System - Event log                    +
01/07/2010 12:44:13 (Std)    +                          (http://www.cegui.org.uk/)                         +
01/07/2010 12:44:13 (Std)    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

01/07/2010 12:44:13 (Std)    CEGUI::Logger singleton created. (09F1F3B8)
01/07/2010 12:44:13 (Std)    
01/07/2010 12:44:13 (Std)    ********************************************************************************
01/07/2010 12:44:13 (Std)    * Important:                                                                   *
01/07/2010 12:44:13 (Std)    *     To get support at the CEGUI forums, you must post _at least_ the section *
01/07/2010 12:44:13 (Std)    *     of this log file indicated below.  Failure to do this will result in no  *
01/07/2010 12:44:13 (Std)    *     support being given; please do not waste our time.                       *
01/07/2010 12:44:13 (Std)    ********************************************************************************
01/07/2010 12:44:13 (Std)    ********************************************************************************
01/07/2010 12:44:13 (Std)    * -------- START OF ESSENTIAL SECTION TO BE POSTED ON THE FORUM       -------- *
01/07/2010 12:44:13 (Std)    ********************************************************************************
01/07/2010 12:44:13 (Std)    ---- Version 0.7.1 (Build: Jul  1 2010 Static Debug Microsoft Windows MSVC++ 8.0 32 bit) ----
01/07/2010 12:44:13 (Std)    ---- Renderer module is:   TextureTarget support enabled via FBO extension. ----
01/07/2010 12:44:13 (Std)    ---- XML Parser module is: CEGUI::ExpatParser - Official expat based parser module for CEGUI ----
01/07/2010 12:44:13 (Std)    ---- Image Codec module is: FreeImageCodec - FreeImage based image codec ----
01/07/2010 12:44:13 (Std)    ---- Scripting module is: None ----
01/07/2010 12:44:13 (Std)    ********************************************************************************
01/07/2010 12:44:13 (Std)    * -------- END OF ESSENTIAL SECTION TO BE POSTED ON THE FORUM         -------- *
01/07/2010 12:44:13 (Std)    ********************************************************************************
01/07/2010 12:44:13 (Std)    
01/07/2010 12:44:13 (Std)    ---- Begining CEGUI System initialisation ----
01/07/2010 12:44:17 (Std)    CEGUI::ImagesetManager singleton created (09F243D8)
01/07/2010 12:44:17 (Std)    CEGUI::FontManager singleton created. (09F24E10)
01/07/2010 12:44:17 (Std)    CEGUI::WindowFactoryManager singleton created
01/07/2010 12:44:17 (Std)    CEGUI::WindowManager singleton created (09F25538)
01/07/2010 12:44:17 (Std)    CEGUI::SchemeManager singleton created. (09F257A8)
01/07/2010 12:44:17 (Std)    CEGUI::MouseCursor singleton created. (09F25A90)
01/07/2010 12:44:17 (Std)    CEGUI::GlobalEventSet singleton created. (09F25D40)
01/07/2010 12:44:17 (Std)    CEGUI::WidgetLookManager singleton created. (09F25E90)
01/07/2010 12:44:17 (Std)    CEGUI::WindowRendererManager singleton created (09F26108)
01/07/2010 12:44:18 (Std)    Created WindowFactory for '' windows.
01/07/2010 12:44:18 (Std)    WindowFactory for '' windows added. (09F26248)
01/07/2010 12:48:18 (Std)    Created WindowFactory for '' windows.
01/07/2010 12:50:44 (Error)   CEGUI::AlreadyExistsException in file d:\res_v4\test_cegui\lib\external-libs\cegui-0.7.1\cegui\src\ceguiwindowfactorymanager.cpp(80) : WindowFactoryManager::addFactory - A WindowFactory for type '' is already registered.
01/07/2010 12:50:44 (Std)    Deleted WindowFactory for '' windows.


It seems something goes wrong while initializing factory objects... Any clue?

User avatar
scriptkid
Home away from home
Home away from home
Posts: 1178
Joined: Wed Jan 12, 2005 12:06
Location: The Hague, The Netherlands
Contact:

Re: Error initializing CEGUI

Postby scriptkid » Thu Jul 01, 2010 13:44

Hi,

[edit]
Checking with a logfile of a correct launch shows that the first line has todo with the DefaultWindow, which is not defined in an XML file. This makes it an odd issue. I don't have all code at hand. But it might still be wise to post that scheme file ;)
[/edit]

These lines:

Code: Select all

Created WindowFactory for '' windows


Should have a name between the quotes. There seems to be a problem with your .scheme file, can you post it?
Check out my released snake game using Cegui!

strangedays
Not too shy to talk
Not too shy to talk
Posts: 27
Joined: Fri Jun 06, 2008 15:25

Re: Error initializing CEGUI

Postby strangedays » Thu Jul 01, 2010 13:51

i don't have any .scheme file placed in my /bin folder.... should I copy some configuration file such as the /datafiles folder in the executable folder?

strangedays
Not too shy to talk
Not too shy to talk
Posts: 27
Joined: Fri Jun 06, 2008 15:25

Re: Error initializing CEGUI

Postby strangedays » Thu Jul 01, 2010 13:52

Taking a look to internal code, looks like that factories are built using a kind of String TypeID which is a const static class value.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: Error initializing CEGUI

Postby CrazyEddie » Thu Jul 01, 2010 14:04

This:

Code: Select all

 CEGUI::System::create( CEGUI::OpenGLRenderer::create() );

has to be done within the main body of code. It can not be done directly statically, or indirectly statically (such as in the constructor of some object you statically create). Remember that order of initialisation for static items in different .o files within the same module are not guaranteed.

CE.

strangedays
Not too shy to talk
Not too shy to talk
Posts: 27
Joined: Fri Jun 06, 2008 15:25

Re: Error initializing CEGUI

Postby strangedays » Thu Jul 01, 2010 14:30

I am not sure what I should do and maybe I didn't understand.

I am taking a look to your header classes. I guess a significant change has occoured between 0.6.x versions to 0.7.x since I may only initialize renderer and system object using static class methods such as create and destroy... By the way, I am running it on Windows ( there fore not using .o libs ).

My project builds a .dll library which is explicitly loaded at runtime ( using LoadLib ). My library links a CEGUI_Base_static.lib . I was wondering if these kind of problems would occour when trying to initialize a static variable over a dynamic contenent such as my project.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: Error initializing CEGUI

Postby CrazyEddie » Thu Jul 01, 2010 17:13

Ok, I think much of the discussion is now at cross purposes, due to ambiguity of 'static' meaning multiple things ;)

We have:
  • initialisation of static data
  • static member function calls
  • static linking.
For the purposes of what I was talking about, only the first item on that list is to be considered; obviously you have to use the static member functions and static linking is largely irrelevant (though see below about c/c++ runtime configs).

The .o/.obj file thing relates to static linking. A static lib is just an archive of compiled translation units (i.e a bunch of .o or .obj files stuck together). Static data in a given translation unit is (I believe) initialised in order of definition. However, across translation units, order of initialisation is unspecified. This means that when you statically link, you're joining a whole load of .obj files together into the final module (.exe / .dll) and the order of initialisation for each linked in .o / .obj file is unknown.

So why is that important? Generally, it's not. However, the presence of uninitialised static strings tells me that either the CEGUI system is being constructed along with other 'global' level static data, and therefore is being constructed before the static strings are initialised, or perhaps there's an issue with c/c++ runtime (see below). To revisit my original point: Where is that code snippet you posted in related to other code? When does that get called? If it's called either directly or indirectly (as I said, perhaps in the constructor of some other class you have) before the main / WinMain function is entered, then this is what is causing the issue - that call must be made after you know that static data has been initialised, and the only time you know that's the case is once the application entry point is reached.

One final possibility could be a heap issue if you're mixing and matching c/c++ runtime libraries. All parts of the app must be built with the same c/c++ runtime setting. By default the static CEGUI libs will be using the multithreaded static runtime (/MT and /MTd settings), if your app is using the /MD and /MDd settings, you need to rebuild CEGUI with the STATIC_BUILD_WITH_DYNAMIC_DEPS option set to true.

CE.

strangedays
Not too shy to talk
Not too shy to talk
Posts: 27
Joined: Fri Jun 06, 2008 15:25

Re: Error initializing CEGUI

Postby strangedays » Fri Jul 02, 2010 09:17

Thank you Eddie for your explaination! I really appreciate! I will do further investigation about this issue related to dynamic explicit linking.

Since it is a lot of code regarding this engine it is quite difficult to copy and paste the whole thing. I will do a summary.

This engine is a OpenGL based core application. This application uses a an initialization file which tells this engine in which sequence it has to load DLL files using LoadLib.
example:

Code: Select all

[modules]
library1.dll
library2.dll
library3.dll


Imagine that my library is library3.dll. At a certain point, during engine initialization, this engine will load library3.dll. library3.dll builds in CEGUI_Base_Static.lib.

Something that looks like that ( entrypoint: dllMain.cpp )

Code: Select all

#if defined(EXPORTLIB )
#define DllExport __declspec(dllexport)
#else
#define DllExport __declspec(dllimport)
#endif

DllExport void Init()
{
   IShape*pTest = new CeguiTest();
}


Following this constructor will be invoked:

Code: Select all

CeguiTest::CeguiTest()
: IShape()
{
    CEGUI::System::create( CEGUI::OpenGLRenderer::create() );
}


Here it goes CEGUI initialization... and, of course, my static data initialization problem.

Of course I am opened to any suggestion regarding this particular issue.


Return to “Help”

Who is online

Users browsing this forum: Bing [Bot] and 23 guests