[SOLVED]crash when debugging release version(static linking)

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

Savail
Quite a regular
Quite a regular
Posts: 50
Joined: Wed Jul 04, 2012 07:54

[SOLVED]crash when debugging release version(static linking)

Postby Savail » Tue Aug 07, 2012 19:16

Hey,
I'm using microsoft visual C++ express 2010 and I'm statically linking my application. I have Multi-threaded (/MT) for relase set and Multi-threaded Debug (/MTd) for debug mode.Compiling the release version (in release mode) works fine. Lately I had to debug my application to locate some errors in my application and just then noticed that my release version in debug mode fails. Though everything works fine if I link dynamically.
Here's call stack:

Code: Select all

    ntdll.dll!7c90120e()    
    [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]   
    ntdll.dll!7c96ee31()    
    ntdll.dll!7c96f26e()    
    ntdll.dll!7c970456()    
    ntdll.dll!7c94bafc()    
    ntdll.dll!7c91a1ba()    
    ntdll.dll!7c919c0c()    
    ntdll.dll!7c919f68()    
    ntdll.dll!7c919c0c()    
    ntdll.dll!7c919f68()    
    ntdll.dll!7c919c0c()    
    gdi32.dll!77f521c4()    
>   LF.exe!malloc(unsigned int size)  Line 89 + 0x3b bytes   C
    ffffff90()   

cegui.log:

Code: Select all

07/08/2012 21:04:02 (Std)    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
07/08/2012 21:04:02 (Std)    +                     Crazy Eddie's GUI System - Event log                    +
07/08/2012 21:04:02 (Std)    +                          (http://www.cegui.org.uk/)                         +
07/08/2012 21:04:02 (Std)    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

07/08/2012 21:04:02 (Std)    CEGUI::Logger singleton created. (00B0CC00)
07/08/2012 21:04:02 (Std)    
07/08/2012 21:04:02 (Std)    ********************************************************************************
07/08/2012 21:04:02 (Std)    * Important:                                                                   *
07/08/2012 21:04:02 (Std)    *     To get support at the CEGUI forums, you must post _at least_ the section *
07/08/2012 21:04:02 (Std)    *     of this log file indicated below.  Failure to do this will result in no  *
07/08/2012 21:04:02 (Std)    *     support being given; please do not waste our time.                       *
07/08/2012 21:04:02 (Std)    ********************************************************************************
07/08/2012 21:04:02 (Std)    ********************************************************************************
07/08/2012 21:04:02 (Std)    * -------- START OF ESSENTIAL SECTION TO BE POSTED ON THE FORUM       -------- *
07/08/2012 21:04:02 (Std)    ********************************************************************************
07/08/2012 21:04:02 (Std)    ---- Version 0.7.8 (Build: Jul 21 2012 Microsoft Windows MSVC++ 10.0 32 bit) ----
07/08/2012 21:04:02 (Std)    ---- Renderer module is: CEGUI::Direct3D9Renderer - Official Direct3D 9 based 2nd generation renderer module. ----
07/08/2012 21:04:02 (Std)    ---- XML Parser module is: CEGUI::ExpatParser - Official expat based parser module for CEGUI ----
07/08/2012 21:04:02 (Std)    ---- Image Codec module is: SILLYImageCodec - Official SILLY based image codec ----
07/08/2012 21:04:02 (Std)    ---- Scripting module is: None ----
07/08/2012 21:04:02 (Std)    ********************************************************************************
07/08/2012 21:04:02 (Std)    * -------- END OF ESSENTIAL SECTION TO BE POSTED ON THE FORUM         -------- *
07/08/2012 21:04:02 (Std)    ********************************************************************************
07/08/2012 21:04:02 (Std)    
07/08/2012 21:04:02 (Std)    ---- Begining CEGUI System initialisation ----
07/08/2012 21:04:02 (Std)    CEGUI::ImagesetManager singleton created (00B0C500)
07/08/2012 21:04:02 (Std)    CEGUI::FontManager singleton created. (00B0CF58)
07/08/2012 21:04:02 (Std)    CEGUI::WindowFactoryManager singleton created
07/08/2012 21:04:02 (Std)    ---- Adding pre-registered WindowFactory objects ----
07/08/2012 21:04:02 (Std)    WindowFactory for 'AlphaHitWindow' windows added. (00C02980)
07/08/2012 21:04:02 (Std)    CEGUI::WindowManager singleton created (00B02408)
07/08/2012 21:04:02 (Std)    CEGUI::SchemeManager singleton created. (00B0F370)
07/08/2012 21:04:02 (Std)    CEGUI::MouseCursor singleton created. (00AEC520)
07/08/2012 21:04:02 (Std)    CEGUI::GlobalEventSet singleton created. (00B0A728)
07/08/2012 21:04:02 (Std)    CEGUI::AnimationManager singleton created (00B05E98)
07/08/2012 21:04:02 (Std)    CEGUI::WidgetLookManager singleton created. (00B052D0)
07/08/2012 21:04:02 (Std)    CEGUI::WindowRendererManager singleton created (00B02DB8)
07/08/2012 21:04:02 (Std)    CEGUI::RenderEffectManager singleton created (00B02DE0)
07/08/2012 21:04:02 (Std)    Created WindowFactory for 'DefaultWindow' windows.
07/08/2012 21:04:02 (Std)    WindowFactory for 'DefaultWindow' windows added. (00B108F8)

Hmm so it seems that cegui crashes while debugging release version with static linking in its initialisation but I have no idea why. And after getting the error:

Code: Select all

Windows has triggered a breakpoint in LF.exe.

This may be due to a corruption of the heap, which indicates a bug in LF.exe or any of the DLLs it has loaded.

This may also be due to the user pressing F12 while LF.exe has focus.

The output window may have more diagnostic information.

I can press continue in my project's debug options and game runs properly. I suppose I'm doing everything properly there but here's initialisation code:

Code: Select all

using namespace CEGUI;
   CEGUI::WindowFactoryManager::addFactory<CEGUI::TplWindowFactory<AlphaHitWindow> >();
   myRenderer = &CEGUI::Direct3D9Renderer::bootstrapSystem( Input::Obj().d3dDevice );

   DefaultResourceProvider* rp = static_cast<DefaultResourceProvider*>(CEGUI::System::getSingleton().getResourceProvider());
   
   rp->setResourceGroupDirectory("schemes", "schemes/");
   rp->setResourceGroupDirectory("imagesets", "sprite/");
   rp->setResourceGroupDirectory("fonts", "fonts/");
   rp->setResourceGroupDirectory("layouts", "layouts/");
   rp->setResourceGroupDirectory("looknfeels", "looknfeel/");

   CEGUI::Imageset::setDefaultResourceGroup("imagesets");
   CEGUI::Font::setDefaultResourceGroup("fonts");
   CEGUI::Scheme::setDefaultResourceGroup("schemes");
   CEGUI::WidgetLookManager::setDefaultResourceGroup("looknfeels");
   CEGUI::WindowManager::setDefaultResourceGroup("layouts");

   CEGUI::SchemeManager::getSingleton().create( "Game.scheme" );
   CEGUI::FontManager::getSingleton().create( "NEORD.font" );

   System::getSingleton().setDefaultFont( "NEORD" );
   System::getSingleton().setDefaultMouseCursor( "Game", "MouseArrow" );
   
   Input::Obj().d3dDevice->CreateStateBlock( D3DSBT_ALL, &pStateBlock );

   WindowManager& wmgr = WindowManager::getSingleton();
   myRoot = wmgr.createWindow( "DefaultWindow", "root" );
   System::getSingleton().setGUISheet( myRoot );
Last edited by Savail on Wed Aug 08, 2012 19:41, edited 1 time in total.

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: crash when debugging release version (static linking)

Postby Kulik » Tue Aug 07, 2012 19:59

Seen this hundred times, it's most likely runtime mismatch, Windows is really picky regarding this...

Make sure EVERYTHING links to the right runtime.

Savail
Quite a regular
Quite a regular
Posts: 50
Joined: Wed Jul 04, 2012 07:54

Re: crash when debugging release version (static linking)

Postby Savail » Tue Aug 07, 2012 20:22

thanks a lot for answer!
but hmm actually maybe I'm bad at static linking at all :P. I've moved my game's exe and necessary data(all compiled in release mode) to a separate folder without dlls. After running it error pops up that CEGUIBase.dll is missing :|. But I thought I've already linked that statically. Isn't setting Multi-threaded (/MT) for release version enough to statically link application with all dlls it loads?
I'm not quite sure what do you mean by runtime mismatch (becouse of my english). I have just compiled CEGUI to newest version both in release and debug mode and copied necessary dlls (with _d suffix and without it) to my game's folder. But the error still occurs :(

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: crash when debugging release version (static linking)

Postby Kulik » Tue Aug 07, 2012 23:40

Do not use static linking unless you have a very solid reason for it. I understand it just before shipping the title but definitely not for development.

There are many additional pitfalls when compared to dynamic linking. If you are unsure how it all works just use dynamic linking, it's definitely less error prone.

I meant the MSVC runtime.

MorbidAngel
Just popping in
Just popping in
Posts: 18
Joined: Sat Aug 04, 2012 16:35

Re: crash when debugging release version (static linking)

Postby MorbidAngel » Tue Aug 07, 2012 23:40

Setting /MT will make it link with static MSVC++ lib compile CEGUI with /MT as well in this case and include the CEGUI libs in your application in linker section (remember the dependencies as well. dependencies/lib/static)

Savail
Quite a regular
Quite a regular
Posts: 50
Joined: Wed Jul 04, 2012 07:54

Re: crash when debugging release version (static linking)

Postby Savail » Wed Aug 08, 2012 18:51

thanks for answers.
Though I still can't manage to link cegui statically. Would anyone be so kind to give me clues step by step what should be done to do it? I compiled whole CEGUI solution with Multi-threaded (/MT) option for both release(creates dlls) and release_static(creates libs) modes. Though I had to ignore additionally libcmt.lib for 3 projects in order to compile them(CEGUIBase CEGUICorona and something else :P). Now I have in my project Multi-threaded (/MT) set and these are my additional dependencies: CEGUIBase_Static.lib;CEGUIDirect3D9Renderer_Static.lib;CEGUIExpatParser_Static.lib;CEGUIFalagardWRBase_Static.lib;CEGUISILLYImageCodec_Static.lib;
SILLY.lib. But I get following errors and can't fix them :/.
//deleted
Thanks a lot for your current time guys. I really appreciate your help!

edit: hmm while surfing the internet I came across information that I have to set preprocessor macro called CEGUI_STATIC in C++/Preprocessor definitions. So I did and I have now about 100 less errors but still can't fix those:

Code: Select all

1>CEGUIBase_Static.lib(CEGUIFreeTypeFont.obj) : error LNK2001: unresolved external symbol _FT_Load_Char
1>CEGUIBase_Static.lib(CEGUIFreeTypeFont.obj) : error LNK2001: unresolved external symbol _FT_Done_Face
1>CEGUIBase_Static.lib(CEGUIFreeTypeFont.obj) : error LNK2001: unresolved external symbol _FT_Get_Next_Char
1>CEGUIBase_Static.lib(CEGUIFreeTypeFont.obj) : error LNK2001: unresolved external symbol _FT_Get_First_Char
1>CEGUIBase_Static.lib(CEGUIFreeTypeFont.obj) : error LNK2001: unresolved external symbol _FT_Set_Char_Size
1>CEGUIBase_Static.lib(CEGUIFreeTypeFont.obj) : error LNK2001: unresolved external symbol _FT_New_Memory_Face
1>CEGUIBase_Static.lib(CEGUIFreeTypeFont.obj) : error LNK2001: unresolved external symbol _FT_Init_FreeType
1>CEGUIBase_Static.lib(CEGUIFreeTypeFont.obj) : error LNK2001: unresolved external symbol _FT_Done_FreeType
1>CEGUIBase_Static.lib(CEGUIPCRERegexMatcher.obj) : error LNK2001: unresolved external symbol _pcre_free
1>CEGUIBase_Static.lib(CEGUIPCRERegexMatcher.obj) : error LNK2001: unresolved external symbol _pcre_compile
1>CEGUIBase_Static.lib(CEGUIPCRERegexMatcher.obj) : error LNK2001: unresolved external symbol _pcre_exec
1>CEGUIExpatParser_Static.lib(CEGUIExpatParser.obj) : error LNK2001: unresolved external symbol _XML_ParserFree
1>CEGUIExpatParser_Static.lib(CEGUIExpatParser.obj) : error LNK2001: unresolved external symbol _XML_ErrorString
1>CEGUIExpatParser_Static.lib(CEGUIExpatParser.obj) : error LNK2001: unresolved external symbol _XML_GetErrorCode
1>CEGUIExpatParser_Static.lib(CEGUIExpatParser.obj) : error LNK2001: unresolved external symbol _XML_GetCurrentLineNumber
1>CEGUIExpatParser_Static.lib(CEGUIExpatParser.obj) : error LNK2001: unresolved external symbol _XML_Parse
1>CEGUIExpatParser_Static.lib(CEGUIExpatParser.obj) : error LNK2001: unresolved external symbol _XML_SetCharacterDataHandler
1>CEGUIExpatParser_Static.lib(CEGUIExpatParser.obj) : error LNK2001: unresolved external symbol _XML_SetElementHandler
1>CEGUIExpatParser_Static.lib(CEGUIExpatParser.obj) : error LNK2001: unresolved external symbol _XML_SetUserData
1>CEGUIExpatParser_Static.lib(CEGUIExpatParser.obj) : error LNK2001: unresolved external symbol _XML_ParserCreate
1>SILLY.lib(SILLYPNGImageLoader.obj) : error LNK2001: unresolved external symbol _png_error
1>SILLY.lib(SILLYPNGImageLoader.obj) : error LNK2001: unresolved external symbol _png_get_io_ptr
1>SILLY.lib(SILLYPNGImageLoader.obj) : error LNK2001: unresolved external symbol _png_get_channels
1>SILLY.lib(SILLYPNGImageLoader.obj) : error LNK2001: unresolved external symbol _png_get_bit_depth
1>SILLY.lib(SILLYPNGImageLoader.obj) : error LNK2001: unresolved external symbol _png_read_png
1>SILLY.lib(SILLYPNGImageLoader.obj) : error LNK2001: unresolved external symbol _png_set_read_fn
1>SILLY.lib(SILLYPNGImageLoader.obj) : error LNK2001: unresolved external symbol _png_set_error_fn
1>SILLY.lib(SILLYPNGImageLoader.obj) : error LNK2001: unresolved external symbol _png_set_longjmp_fn
1>SILLY.lib(SILLYPNGImageLoader.obj) : error LNK2001: unresolved external symbol _png_create_info_struct
1>SILLY.lib(SILLYPNGImageLoader.obj) : error LNK2001: unresolved external symbol _png_create_read_struct
1>SILLY.lib(SILLYPNGImageLoader.obj) : error LNK2001: unresolved external symbol _png_get_rows
1>SILLY.lib(SILLYJPGImageLoader.obj) : error LNK2001: unresolved external symbol _jpeg_finish_decompress
1>SILLY.lib(SILLYJPGImageLoader.obj) : error LNK2001: unresolved external symbol _jpeg_start_decompress
1>SILLY.lib(SILLYJPGImageLoader.obj) : error LNK2001: unresolved external symbol _jpeg_read_header
1>SILLY.lib(SILLYJPGImageLoader.obj) : error LNK2001: unresolved external symbol _jpeg_read_scanlines
1>SILLY.lib(SILLYPNGImageContext.obj) : error LNK2001: unresolved external symbol _png_destroy_read_struct
1>SILLY.lib(SILLYPNGImageContext.obj) : error LNK2001: unresolved external symbol _png_get_image_height
1>SILLY.lib(SILLYPNGImageContext.obj) : error LNK2001: unresolved external symbol _png_get_image_width
1>SILLY.lib(SILLYJPGImageContext.obj) : error LNK2001: unresolved external symbol _jpeg_std_error
1>SILLY.lib(SILLYJPGImageContext.obj) : error LNK2001: unresolved external symbol _jpeg_CreateDecompress
1>SILLY.lib(SILLYJPGImageContext.obj) : error LNK2001: unresolved external symbol _jpeg_resync_to_restart
1>SILLY.lib(SILLYJPGImageContext.obj) : error LNK2001: unresolved external symbol _jpeg_destroy_decompress
1>D:\visual_DX_programy\LF\Release\LF.exe : fatal error LNK1120: 42 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Last edited by Savail on Wed Aug 08, 2012 19:46, edited 2 times in total.

MorbidAngel
Just popping in
Just popping in
Posts: 18
Joined: Sat Aug 04, 2012 16:35

Re: crash when debugging release version (static linking)

Postby MorbidAngel » Wed Aug 08, 2012 19:22

You didn't include the dependency libs as i said before. (dependencies\lib\static) freetype.lib / pcre.lib / expat.lib / SILLY.lib

Savail
Quite a regular
Quite a regular
Posts: 50
Joined: Wed Jul 04, 2012 07:54

Re: crash when debugging release version (static linking)

Postby Savail » Wed Aug 08, 2012 19:33

yeah I've just added those, I'm really bad at it but thansk to your help I've managed to link it eventually :D. Thanks a lot. For others the complete list of additional dependencies in microsoft visual c++ is:

Code: Select all

CEGUIBase_Static.lib
CEGUIDirect3D9Renderer_Static.lib
CEGUIExpatParser_Static.lib
CEGUIFalagardWRBase_Static.lib
CEGUISILLYImageCodec_Static.lib
SILLY.lib
pcre.lib
expat.lib
freetype.lib
libpng.lib
jpeg.lib
zlib.lib

and libs coming from dependendencies folder must be from static subfolder of course


Return to “Help”

Who is online

Users browsing this forum: No registered users and 3 guests