Using wxWidgets.DLL in an exe and another application dll

906 views
Skip to first unread message

murali

unread,
Dec 30, 2009, 9:10:13 AM12/30/09
to wx-u...@lists.wxwidgets.org
Hello,

My environment is as follows:

WX : 2.8.10
OS : Windows XP
COMPILER: VC9 (using IDE)

I need help for building wxWidgets as DLL, and then to use it in:
a) Proj1 that creates an exe
b) Proj2 that creates a DLL

Both use wxWidgets.

The exe creates a wxWindow (say W1) and a wxButton (say B) on it. When the
button B is clicked, the exe(Proj1) loads the DLL(Proj2) and calls a function
from it, which creates a wxWindow (say W2) whose parent is W1.

Questions:
1) How to build wxWidgets as a monolithic DLL? (so that it can be used by both
exe and DLL)
2) How to use wxWidgets in a DLL project? That is how to create a VC++ project
that uses wxWidgets, and creates a DLL when built.


Thanks and regards,
murali

Vadim Zeitlin

unread,
Dec 30, 2009, 6:00:58 PM12/30/09
to wx-u...@googlegroups.com
On Wed, 30 Dec 2009 14:10:13 +0000 (UTC) murali <mural...@gmail.com> wrote:

m> I need help for building wxWidgets as DLL, and then to use it in:
m> a) Proj1 that creates an exe
m> b) Proj2 that creates a DLL
m>
m> Both use wxWidgets.
m>
m> The exe creates a wxWindow (say W1) and a wxButton (say B) on it. When the
m> button B is clicked, the exe(Proj1) loads the DLL(Proj2) and calls a function
m> from it, which creates a wxWindow (say W2) whose parent is W1.
m>
m> Questions:
m> 1) How to build wxWidgets as a monolithic DLL? (so that it can be used by both
m> exe and DLL)

Why does it need to be monolithic? A normal DLL build should work just as
well. If you really need to build it monolithically, you can use
makefile.vc in the usual way but add MONOLITHIC=1 on nmake command line. If
you want a project file for monolithic build then you need to create it
using bakefile_gen.

m> 2) How to use wxWidgets in a DLL project? That is how to create a VC++
m> project that uses wxWidgets, and creates a DLL when built.

There is nothing special to do, just create a normal DLL project (using
the wizard or by hand, depending on your preferences) and use wx from it.

IOW I don't really understand what problem are you trying to solve, what
you want to do should just work.

Regards,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/

Aniruddha Apte

unread,
Dec 31, 2009, 1:49:17 AM12/31/09
to wx-u...@lists.wxwidgets.org
Vadim Zeitlin <vadim <at> wxwidgets.org> writes:
> Why does it need to be monolithic? A normal DLL build should work just as
> well. If you really need to build it monolithically, you can use
> makefile.vc in the usual way but add MONOLITHIC=1 on nmake command line. If
> you want a project file for monolithic build then you need to create it
> using bakefile_gen.
Thanks for your reply Vadim.
Yes I was able to build all wx dll's by using wx_dll.dsw.

> There is nothing special to do, just create a normal DLL project (using
> the wizard or by hand, depending on your preferences) and use wx from it.
>
> IOW I don't really understand what problem are you trying to solve, what
> you want to do should just work.

The actual use-case is that we have a main application exe that uses wx and this
main exe will load multiple other dll's that implement certain independent
functionality and have their own ui. This is done by having the dll's create and
show some kind of a child window inside the main frame. These dll's will also
use wx for the ui. So, could you please help with using wx dll's in the main
application exe as well as the other dll's?

Specifically, we need to know which wx dll's to include in the VC++ express
project properties for the linker. Do we need to use any .lib or .def files so
that the exported wx api's are callable? Do we need to use LoadLibrary() to load
the wx dll's and then call GetProcAddress()?

Also, are there any special things to take care of when initing the wx dll's
since they will be used from the main exe and also the other dll's?

Thanks in advance,
aniruddha


iko...@earthlink.net

unread,
Dec 31, 2009, 3:26:58 AM12/31/09
to wx-u...@googlegroups.com, wx-u...@lists.wxwidgets.org
Hi, Ani,
I am not Vadim, but I will try to help you with this topic. ;-)

-----Original Message-----
>From: Aniruddha Apte <ani...@gmail.com>
>Sent: Dec 30, 2009 10:49 PM
>To: wx-u...@lists.wxwidgets.org
>Subject: Re: Using wxWidgets.DLL in an exe and another application dll
>
>Vadim Zeitlin <vadim <at> wxwidgets.org> writes:
>> There is nothing special to do, just create a normal DLL project (using
>> the wizard or by hand, depending on your preferences) and use wx from it.
>>
>> IOW I don't really understand what problem are you trying to solve, what
>> you want to do should just work.
>
>The actual use-case is that we have a main application exe that uses wx and this
>main exe will load multiple other dll's that implement certain independent
>functionality and have their own ui. This is done by having the dll's create and
>show some kind of a child window inside the main frame. These dll's will also
>use wx for the ui. So, could you please help with using wx dll's in the main
>application exe as well as the other dll's?

What kind of problems do you have right now?
IOW are able to build you app/DLL successfully? If not what errors do you get?

>
>Specifically, we need to know which wx dll's to include in the VC++ express
>project properties for the linker. Do we need to use any .lib or .def files so
>that the exported wx api's are callable? Do we need to use LoadLibrary() to load
>the wx dll's and then call GetProcAddress()?

For any wx projects, either main app or DLL, you can start by using wx{base,core}
libraries and work you way out in case the link will fail. There is no specific
or special flags that you have to use to build the DLL. Like Vadim said just
create the project inside the VS IDE and add the include/lib path.
You don't need to use LoadLibrary() to use wx, however, you will need to use
this function in order to use you DLL inside you app. Just don't forget to use
WXEXPORT macro for the function that you will call from the main app, just
so the dynamic linnking can be done.

>
>Also, are there any special things to take care of when initing the wx dll's
>since they will be used from the main exe and also the other dll's?

There is no special things. Just crete a DLL project add files, change compiler
settings for C++/Linker, compile and run.

Thank you.

>
>Thanks in advance,
>aniruddha
>
>
>
>
>--
>Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
>
>To unsubscribe, send email to wx-users+u...@googlegroups.com
>or visit http://groups.google.com/group/wx-users

murali iyengar

unread,
Dec 31, 2009, 6:18:32 AM12/31/09
to wx-users
Hi Iko,
Thanks for your reply..

My problem is that it is *not creating the .DLL file when i build the
DLL project.
It is giving some linker errors. I've listed down the errors below,
after listing my project settings.

My settings in the property page are as follows:

C/C++ -> General -> Additional Include Directories:
.\..\..\..\lib\vc_lib\mswd
.\..\..\..\include
.
.\..\..\..\samples

C/C++ -> Preprocessor -> Preprocessor Definitions:
WIN32
_DEBUG
__WXMSW__
__WXDEBUG__
_WINDOWS
_USRDLL
MY_DLL_NEW_EXPORTS

Linker -> General -> -> Additional Library Directories:
.\..\..\..\lib\vc_lib

Linker -> Input -> Additional Dependencies:
wxmsw28d_core.lib
wxbase28d.lib
comctl32.lib
rpcrt4.lib

LINKER ERRORS:

Linking...
Creating library D:\wxWidgets-2.8.10\samples\my_dll_new\Debug
\my_dll_new.lib and object D:\wxWidgets-2.8.10\samples\my_dll_new\Debug
\my_dll_new.exp
my_dll_new.obj : error LNK2001: unresolved external symbol "wchar_t
const * const wxPanelNameStr" (?wxPanelNameStr@@3QB_WB)
my_dll_new.obj : error LNK2019: unresolved external symbol "protected:
void __thiscall wxStringBase::InitWith(wchar_t const *,unsigned
int,unsigned int)" (?InitWith@wxStringBase@@IAEXPB_WII@Z) referenced
in function "public: __thiscall wxStringBase::wxStringBase(wchar_t
const *)" (??0wxStringBase@@QAE@PB_W@Z)
my_dll_new.obj : error LNK2019: unresolved external symbol "void
__cdecl wxOnAssert(wchar_t const *,int,char const *,wchar_t const
*,wchar_t const *)" (?wxOnAssert@@YAXPB_WHPBD00@Z) referenced in
function "public: __thiscall wxStringBase::wxStringBase(class
wxStringBase const &)" (??0wxStringBase@@QAE@ABV0@@Z)
my_dll_new.obj : error LNK2001: unresolved external symbol "wchar_t
const * const wxEmptyString" (?wxEmptyString@@3PB_WB)
D:\wxWidgets-2.8.10\samples\my_dll_new\Debug\my_dll_new.dll : fatal
error LNK1120: 4 unresolved externals
Build log was saved at "file://d:\wxWidgets-2.8.10\samples\my_dll_new
\my_dll_new\Debug\BuildLog.htm"
my_dll_new - 5 error(s), 0 warning(s)


Please let me know what is missing.

Thanks and regards,
murali

> >Please readhttp://www.wxwidgets.org/support/mlhowto.htmbefore posting.

Vadim Zeitlin

unread,
Dec 31, 2009, 8:13:41 AM12/31/09
to wx-u...@googlegroups.com
On Thu, 31 Dec 2009 03:18:32 -0800 (PST) murali iyengar <mural...@gmail.com> wrote:

mi> It is giving some linker errors. I've listed down the errors below,
mi> after listing my project settings.

You must define WXUSINGDLL when using wx as a DLL. Please do have a look
at the samples projects, they really contain all the answers.

The recently added to the trunk samples/dll one may be of particular
interest to you.

murali iyengar

unread,
Jan 1, 2010, 4:28:55 AM1/1/10
to wx-users
Hi Vadim,

I could not make it work.

I added WXUSINGDLL into "C/C++ -> Preprocessor -> Preprocessor
Definitions."
and changed lib\vc_lib to lib\vc_dll in the include directories.

Now, when I build, it gives the following linker errors:

Linking...
my_dll_new.obj : error LNK2019: unresolved external symbol "__declspec
(dllimport) public: __thiscall wxString::wxString(wchar_t const
*)" (__imp_??0wxString@@QAE@PB_W@Z) referenced in function "int
__cdecl f(class wxFrame *)" (?f@@YAHPAVwxFrame@@@Z)

my_dll_new.obj : error LNK2001: unresolved external symbol "__declspec
(dllimport) wchar_t const * const wxPanelNameStr" (__imp_?
wxPanelNameStr@@3QB_WB)

D:\wxWidgets-2.8.10\samples\my_dll_new\Debug\my_dll_new.dll : fatal

error LNK1120: 2 unresolved externals


Thanks and regards,
murali


On Dec 31 2009, 6:13 pm, Vadim Zeitlin <va...@wxwidgets.org> wrote:


> On Thu, 31 Dec 2009 03:18:32 -0800 (PST) murali iyengar <muralim...@gmail.com> wrote:
>
> mi> It is giving some linker errors. I've listed down the errors below,
> mi> after listing my project settings.
>
>  You must define WXUSINGDLL when using wx as a DLL. Please do have a look
> at the samples projects, they really contain all the answers.
>
>  The recently added to the trunk samples/dll one may be of particular
> interest to you.
>
>  Regards,
> VZ
>
> --
> TT-Solutions: wxWidgets consultancy and technical support
>                http://www.tt-solutions.com/
>

>  application_pgp-signature_part
> < 1KViewDownload

Krishna

unread,
Jan 1, 2010, 4:48:10 AM1/1/10
to wx-u...@googlegroups.com
On Fri, Jan 1, 2010 at 2:58 PM, murali iyengar <mural...@gmail.com> wrote:
> Hi Vadim,
>
> I could not make it work.
>
> I added WXUSINGDLL into "C/C++ -> Preprocessor -> Preprocessor
> Definitions."
> and changed lib\vc_lib to lib\vc_dll in the include directories.
>
> Now, when I build, it gives the following linker errors:

If my understanding is right, you are building two targets: a DLL and
an app that loads the DLL, right?

The error seems to occur when building the DLL. Try adding WXMAKINGDLL
to the preprocessor flags in your DLL build and WXUSINGDLL only in
your app's preprocessor flags.

Cheers,
--Krishna

--
I long to accomplish a great and noble task, but it is my chief duty
to accomplish small tasks as if they were great and noble !
-- Helen Keller

murali iyengar

unread,
Jan 1, 2010, 5:43:56 AM1/1/10
to wx-users

On Jan 1, 2:48 pm, Krishna <v.krishnaku...@gmail.com> wrote:


> On Fri, Jan 1, 2010 at 2:58 PM, murali iyengar <muralim...@gmail.com> wrote:
> > Hi Vadim,
>
> > I could not make it work.
>
> > I added WXUSINGDLL into "C/C++ -> Preprocessor -> Preprocessor
> > Definitions."
> > and changed lib\vc_lib to lib\vc_dll in the include directories.
>
> > Now, when I build, it gives the following linker errors:
>
> If my understanding is right, you are building two targets: a DLL and
> an app that loads the DLL, right?
>

Thanks krishna.
Yes... this is exactly what i need to accomplish.

> The error seems to occur when building the DLL. Try adding WXMAKINGDLL
> to the preprocessor flags in your DLL build and WXUSINGDLL only in
> your app's preprocessor flags.
>

Yes... the error is in building the DLL.
I tried adding WXMAKINGDLL to the preprocessor flags in my DLL build.
But still it is not working.. it gives hundreds of linker errors.

Can you please help me in creating a DLL project(that uses wxWidgets
for UI) in VC9 ?
Should I use lib\vc_lib OR lib\vc_dll in the DLL project properties ?
What are the preprocessor flags to be used in the DLL project ?
And any other special care to be taken..


> Cheers,
>   --Krishna
>
> --
> I long to accomplish a great and noble task, but it is my chief duty
> to accomplish small tasks as if they were great and noble !
>   -- Helen Keller

Thanks and regards,
murali

Krishna

unread,
Jan 1, 2010, 6:14:19 AM1/1/10
to wx-u...@googlegroups.com
On Fri, Jan 1, 2010 at 4:13 PM, murali iyengar <mural...@gmail.com> wrote:
>
>
>
>
> On Jan 1, 2:48 pm, Krishna <v.krishnaku...@gmail.com> wrote:
>> On Fri, Jan 1, 2010 at 2:58 PM, murali iyengar <muralim...@gmail.com> wrote:
>> > Hi Vadim,
>>
>> > I could not make it work.
>>
>> > I added WXUSINGDLL into "C/C++ -> Preprocessor -> Preprocessor
>> > Definitions."
>> > and changed lib\vc_lib to lib\vc_dll in the include directories.
>>
>> > Now, when I build, it gives the following linker errors:
>>
>> If my understanding is right, you are building two targets: a DLL and
>> an app that loads the DLL, right?
>>
>
> Thanks krishna.
> Yes... this is exactly what i need to accomplish.
>
>> The error seems to occur when building the DLL. Try adding WXMAKINGDLL
>> to the preprocessor flags in your DLL build and WXUSINGDLL only in
>> your app's preprocessor flags.
>>
> Yes... the error is in building the DLL.
> I tried adding WXMAKINGDLL to the preprocessor flags in my DLL build.
> But still it is not working.. it gives hundreds of linker errors.
>
> Can you please help me in creating a DLL project(that uses wxWidgets
> for UI) in VC9 ?
> Should I use lib\vc_lib OR lib\vc_dll in the DLL project properties ?
> What are the preprocessor flags to be used in the DLL project ?
> And any other special care to be taken..
>

I don't use the Visual C++ toolset but I think the following should
get the job done:

* set WXWIN to point to your wxWidgets checkout folder (eg: on my
machine, WXWIN=c:\build\wxWidgets-2.8.10)

* pick a configuration that you want to build (I'm assuming it is
release+wx compiled as a DLL)

* your include path should contain both %WXWIN%\include *and*
%WXWIN%\lib\vc_dll (there are a couple of includes in the lib
directory that adds configuration specific settings to the build)

* your linker/lib path should contain %WXWIN%\lib\vc_dll

* define WXMAKINGDLL when building a DLL with custom widgets and
WXUSINGDLL whenever using a wx dll (in your case I think both the app
and the DLL uses wx so I think you need to supply WXUSINGDLL in both
places)

* add the required wx libs to the library list (eg: wxbase28u.lib
wxmsw28u_core.lib etc)

Compile!

If you are not averse to building from the command line I'd suggest
you take a look at bakefile. It generates nice makefiles. I use
premake(4) which is also quite nice. If you are interested, I'll post
my premake script for building wx projects from which you can generate
visual studio solution.

Vadim Zeitlin

unread,
Jan 1, 2010, 11:18:17 AM1/1/10
to wx-u...@googlegroups.com
On Fri, 1 Jan 2010 01:28:55 -0800 (PST) murali iyengar <mural...@gmail.com> wrote:

mi> I added WXUSINGDLL into "C/C++ -> Preprocessor -> Preprocessor
mi> Definitions."
mi> and changed lib\vc_lib to lib\vc_dll in the include directories.
mi>
mi> Now, when I build, it gives the following linker errors:
mi>
mi> Linking...
mi> my_dll_new.obj : error LNK2019: unresolved external symbol "__declspec
mi> (dllimport) public: __thiscall wxString::wxString(wchar_t const
mi> *)" (__imp_??0wxString@@QAE@PB_W@Z) referenced in function "int
mi> __cdecl f(class wxFrame *)" (?f@@YAHPAVwxFrame@@@Z)
mi>
mi> my_dll_new.obj : error LNK2001: unresolved external symbol "__declspec
mi> (dllimport) wchar_t const * const wxPanelNameStr" (__imp_?
mi> wxPanelNameStr@@3QB_WB)

Do you link with wxcore DLL import library? These symbols ought to be
defined in it.

Anyhow, my previous advice still holds: either create your projects using
a tool which will ensure that they're correct or look at the samples
projects and compare them with yours if you prefer to do it by hand. It's
difficult/impossible to diagnose your problems remotely and it's much
simpler for you to compare your project with a known working one.


Also notice that you must *not* define WXMAKINGDLL in your projects in
spite of advices to the contrary in this thread, this symbol is only used
by wx itself.

Krishna

unread,
Jan 1, 2010, 11:23:13 AM1/1/10
to wx-u...@googlegroups.com
On Fri, Jan 1, 2010 at 9:48 PM, Vadim Zeitlin <va...@wxwidgets.org> wrote:

>  Also notice that you must *not* define WXMAKINGDLL in your projects in
> spite of advices to the contrary in this thread, this symbol is only used
> by wx itself.
>

ok, noted :)

cheers,
--krishna

murali iyengar

unread,
Jan 2, 2010, 8:53:10 AM1/2/10
to wx-users
Hi,

Thanks Vadim, Iko, Krishna.

I could create the DLL successfully.

But there is some problem in using it from other app that also uses
wxWidgets.
It gives "Access violation"

Can you please tell me why it happens ?

Thanks and regards,
murali

iko...@earthlink.net

unread,
Jan 2, 2010, 2:00:21 PM1/2/10
to wx-users
Hi,


-----Original Message-----
>From: murali iyengar <mural...@gmail.com>
>Sent: Jan 2, 2010 5:53 AM
>To: wx-users <wx-u...@googlegroups.com>
>Subject: Re: Using wxWidgets.DLL in an exe and another application dll
>

>Hi,
>
>Thanks Vadim, Iko, Krishna.
>
>I could create the DLL successfully.
>
>But there is some problem in using it from other app that also uses
>wxWidgets.
>It gives "Access violation"
>
>Can you please tell me why it happens ?

Usually it happens when you access the NULL pointer.
Use debugger to see where it crashes and check that you do delete the pointer
when you _don't need it_.

Thank you.

>
>Thanks and regards,
>murali
>
>
>On Jan 1, 9:23 pm, Krishna <v.krishnaku...@gmail.com> wrote:
>> On Fri, Jan 1, 2010 at 9:48 PM, Vadim Zeitlin <va...@wxwidgets.org> wrote:
>> >  Also notice that you must *not* define WXMAKINGDLL in your projects in
>> > spite of advices to the contrary in this thread, this symbol is only used
>> > by wx itself.
>>
>> ok, noted :)
>>
>> cheers,
>>   --krishna
>>
>> --
>> I long to accomplish a great and noble task, but it is my chief duty
>> to accomplish small tasks as if they were great and noble !
>>   -- Helen Keller
>

>--
>Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

murali iyengar

unread,
Jan 4, 2010, 6:38:16 AM1/4/10
to wx-users
Thank You All..

Adding these two lines of code in the dllmain.cpp did the trick.

class Application : public wxApp {};
IMPLEMENT_APP_NO_MAIN(Application)

Thanks and regards,
murali

> >Please readhttp://www.wxwidgets.org/support/mlhowto.htmbefore posting.

murali iyengar

unread,
Jan 5, 2010, 2:31:52 AM1/5/10
to wx-users
Hi All,

I'm writing down the steps to create a DLL project (that uses
wxWidgets) in VC9 below so that it will help those who are facing the
same problem.

DO THE FOLLOWING THINGS FIRST

Add WXWIN to your environment variables and set its value to your
wxWidgets installation folder (In my case it is D:\wxWidgets-2.8.10)

Go to wxWidgets installation folder and browse to build\msw folder.
Run wx.dsw OR wx.sln (It opens in VC)
Right click on the solution (*DONT* right click on any project) and
select "Configuration Manager" from the resulting menu.
In the window that pops up, set the "configuration" for *ALL* projects
to UNICODE DEBUG and close that window.
Then build the solution (f7 OR Right click on solution -> Build
Solution).


STEPS FOR CREATING A DLL PROJECT THAT USES wxWidgets, in VC9:

1. Open VC9 and create a DLL project from the wizard (File -> New ->
Project)

2. Right click on your project (*DONT* right click on the solution)
and select "Properties" from the resulting menu.

3. In the window that pops up, go to "Configuration Properties -> C/C+
+ -> General -> Additional Include Directories". Add the following to
it.
"$(WXWIN)\lib\vc_lib\mswud";"$(WXWIN)\include";.

4. Go to "Configuration Properties -> C/C++ -> Preprocessor ->
Preprocessor Definitions". You would see a few entries there. *DONT*
delete them. Add the following to it.
DLL_EXPORTS;__WXMSW__;_UNICODE

5. Go to "Configuration Properties -> Linker -> General -> Additional
Library Directories". Add the following to it.
"$(WXWIN)\lib\vc_lib"

6. Go to "Configuration Properties -> Linker -> Input -> Additional
Dependencies". Add the following to it.
wxmsw28ud_core.lib wxbase28ud.lib wxtiffd.lib wxjpegd.lib
wxpngd.lib wxzlibd.lib wxregexud.lib wxexpatd.lib kernel32.lib
user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib
comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib
wsock32.lib wininet.lib

7. In your project, there will be 3(three) .cpp files that VC9 has
created for you. they are
dllmain.cpp
stdafx.cpp and
<your_proj_name>.cpp

Edit dllmain.cpp to look like this:

// dllmain.cpp : Defines the entry point for the DLL application.
#include "stdafx.h"

// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"

#ifdef __BORLANDC__
#pragma hdrstop
#endif

// for all others, include the necessary headers (this file is usually
all you
// need because it includes almost all "standard" wxWidgets headers
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif

BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
{
wxSetInstance((HINSTANCE)hModule);
int argc = 0;
char **argv = NULL;
wxEntryStart(argc, argv);
if ( !wxTheApp || !wxTheApp->CallOnInit() )
return FALSE;
}
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
{
wxEntryCleanup();
}
break;
}
return TRUE;
}

class Application : public wxApp {};
IMPLEMENT_APP_NO_MAIN(Application)

8. Open the file <your_proj_name>.cpp, and add the following lines
after the line... #include "stdafx.h"

// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"

#ifdef __BORLANDC__
#pragma hdrstop
#endif

// for all others, include the necessary headers (this file is usually
all you
// need because it includes almost all "standard" wxWidgets headers
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif

9. For every name (function OR class OR ...) in <your_proj_name>.cpp
that you want to export in the dll (to be used by other apps), prefix
the name with extern "C" WXEXPORT.

for example,
extern "C" WXEXPORT void create_my_control(wxPanel* parent)
{
wxTextCtrl *ctrl = new wxTextCtrl(parent, -1, _T("Just for test"),
wxPoint(50,50));
}

AFTER THIS YOU ARE ASSURED TO GET <your_proj_name>.dll WHEN YOU BUILD
THIS PROJECT

Regards,
murali


iko...@earthlink.net

unread,
Jan 5, 2010, 2:47:25 AM1/5/10
to wx-users
Hi, Murali,

Everything looks good. Just one comment.
You don't actually need the DLLMain() function.

And even if you do, it has to be guarded with #ifdef __WXMSW__... #endif

Thank you.


-----Original Message-----
>From: murali iyengar <mural...@gmail.com>
>Sent: Jan 4, 2010 11:31 PM
>To: wx-users <wx-u...@googlegroups.com>
>Subject: Re: Using wxWidgets.DLL in an exe and another application dll
>

>--
>Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

Reply all
Reply to author
Forward
0 new messages