Discussion:
Problem with DLL that uses wxWidgets on Win32
Niels Teusink
2005-06-01 17:16:29 UTC
Permalink
Hi,

I am trying to create a program using wxWidgets that uses dll's. It uses
a loader that starts up the gui wihich is in a dll.
My program runs just fine on Linux, but on Windows it crashes (This
program has generated errors and needs to be closed by Windows etc.)
I have stripped the dll and main program down to a small sample that
only tries to display a couple of wxMessageBoxes.
The program does display the wxMessageBox in main.cpp, but when it comes
to gui.cpp (the dll) it crashes.

I suspect the problem is in the build process of the dll on Windows but
I'm not sure where I should look.

Could anyone point me in the right direction? I have attached the sample
code. I am using mingw-gcc 3.4.3 and wxWindows 2.4.2

Thanks!

Niels

p.s. GDB gives this strange error:

GNU gdb 5.2.1
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i686-pc-mingw32"...
(gdb) run
Starting program: C:\cvstest3\sample/sample.exe

Program received signal SIGSEGV, Segmentation fault.
0x10008da0 in wxMessageDialog::ShowModal() (this=0x22fc30)
at ../../src/msw/msgdlg.cpp:49
49 ../../src/msw/msgdlg.cpp: No such file or directory.
in ../../src/msw/msgdlg.cpp
Current language: auto; currently c++
(gdb) bt
#0 0x10008da0 in wxMessageDialog::ShowModal() (this=0x22fc30)
at ../../src/msw/msgdlg.cpp:49
#1 0x10001a95 in wxMessageBox(wxString const&, wxString const&, long,
wxWindow*
, int, int) (message=@0x22fde0, caption=@0x22fdf0, style=2052, parent=0x0)
at ../../src/common/utilscmn.cpp:709
#2 0x1000123f in load(void*) (arg=0x2182960) at gui.cpp:8
#3 0x10001271 in loadgui (arg=0x2182960) at gui.cpp:12
#4 0x0040148e in Main::OnInit() (this=0x2182960) at main.cpp:24
#5 0x004025a7 in wxEntry(void*, void*, char*, int, bool)
(hInstance=0x400000,
lpCmdLine=0x241efe "", nCmdShow=10, enterLoop=true)
at ../../src/msw/app.cpp:708
#6 0x00403478 in WinMain (hInstance=0x400000, hPrevInstance=0x0,
lpCmdLine=0x241efe "", nCmdShow=10) at ../../src/msw/main.cpp:90
#7 0x004e4bda in main ()
#8 0x004011e7 in _end__ ()
#9 0x00401258 in WinMainCRTStartup ()
#10 0x7c816d4f in _libwsock32_a_iname ()
(gdb) info locals
hWnd = 0x22fda4
msStyle = 268471674
msAns = 2292728
ans = 2088822299
(gdb) quit
The program is running. Exit anyway? (y or n) y
Mark Junker
2005-06-02 03:48:13 UTC
Permalink
Post by Niels Teusink
I am trying to create a program using wxWidgets that uses dll's. It
uses a loader that starts up the gui wihich is in a dll.
Maybe it's a stupid question, but did you build the wxWidgets libraries
as DLLs too? When you didn't, please do it and retry.

Regards,
Mark
Niels Teusink
2005-06-02 15:45:55 UTC
Permalink
Not a stupid question, it pointed me in the right direction :-) I had
built them as DLL's, but it turns out my Windows makefile was using
libwxmsw242d.a instead of wxmsw242d.dll.
Fixing that and WXUSINGDLL=1 did the trick, the sample works!

Thanks!

Niels
Post by Mark Junker
Post by Niels Teusink
I am trying to create a program using wxWidgets that uses dll's. It
uses a loader that starts up the gui wihich is in a dll.
Maybe it's a stupid question, but did you build the wxWidgets
libraries as DLLs too? When you didn't, please do it and retry.
Regards,
Mark
---------------------------------------------------------------------
Loading...