wxWidgets as dll execution problem

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
rodrigod
I live to help wx-kind
I live to help wx-kind
Posts: 172
Joined: Thu Jun 26, 2008 8:50 pm

wxWidgets as dll execution problem

Post by rodrigod » Fri Mar 13, 2009 5:42 pm

In my application I have many dll's. With wxWidgets comiled as a static library everything works great. But when I started to use it as dll, everything compiles but when the dll is loaded during execution the program crashes. I am linking the libraries with the .lib files on windows.

Here is some of the code:

Code: Select all

IMPLEMENT_APP_NO_MAIN(CVBMFCHELPApp) 

DWORD WINAPI ThreadProc(LPVOID lpParameter)
 {
     wxApp::SetInstance(new CVBMFCHELPApp());
     wxEntry(GetModuleHandle(NULL),NULL,NULL,SW_SHOW);
     return true;
 }
 
 #ifdef __WXMSW__
 BOOL APIENTRY DllMain(HANDLE hModule,
                       DWORD  ul_reason_for_call, 
                       LPVOID lpReserved
                       ) 
 {
     switch (ul_reason_for_call)
     { 
     case DLL_PROCESS_ATTACH:
         ThreadId = CreateThread(NULL,0,ThreadProc,NULL,0,NULL);
         break;
     case DLL_THREAD_ATTACH: break;
     case DLL_THREAD_DETACH: break;
     case DLL_PROCESS_DETACH:
         wxEntryCleanup();
         break; 
     }
 
     return TRUE;
It crashes when entering wxEntry.

Any clues on how shed some light on this problem. If you need more info just ask.

Thanks

tan
Moderator
Moderator
Posts: 1471
Joined: Tue Nov 14, 2006 7:58 am
Location: Saint-Petersburg, Russia

Post by tan » Fri Mar 13, 2009 6:38 pm

Hi,
you don't have to use IMPLEMENT_APP_NO_MAIN if you are using WX libs as DLL (on M$ Windows at least).

Code: Select all

#ifndef WXUSINGDLL
IMPLEMENT_APP_NO_MAIN(CVBMFCHELPApp)
#endif
OS: Windows XP Pro
Compiler: MSVC++ 7.1
wxWidgets: 2.8.10

rodrigod
I live to help wx-kind
I live to help wx-kind
Posts: 172
Joined: Thu Jun 26, 2008 8:50 pm

Post by rodrigod » Fri Mar 13, 2009 7:38 pm

Thanks but still not working.

I think its because there isomething that wxentry does that he only allows the main thread to do.

swapd0
I live to help wx-kind
I live to help wx-kind
Posts: 169
Joined: Mon May 14, 2007 11:16 am
Location: Spain

Post by swapd0 » Mon Mar 16, 2009 4:08 pm

I've the same problem when i'm trying to use wxWidgets into an ARX (it's just a dll)

It hangs here module.cpp because wxClassInfo::sm_classTable it's NULL

Code: Select all

void wxModule::RegisterModules()
{
    wxHashTable::compatibility_iterator node;
    wxClassInfo* classInfo;

    wxClassInfo::sm_classTable->BeginFind(); //crash
It's a bit strange because it works ok in AutoCAD 14, maybe my init code it's doing something wrong.

rodrigod
I live to help wx-kind
I live to help wx-kind
Posts: 172
Joined: Thu Jun 26, 2008 8:50 pm

Post by rodrigod » Tue Mar 17, 2009 2:30 am

After some research with the help of the know it all google, it seems that the version 2.8.9 has this bug that with widgets as dll, when you link another dll statically it hangs when loading the dll. It was said that version 2.9.0 had this bug fixed. I am waiting for widgets 3 to update. Any clues as to when it is going to be released, I gave up trying to fix this.

Post Reply