Using DLL Version Of WxWidgets Compiled With Open Watcom

From WxWiki
Jump to navigation Jump to search

Creating a DLL version of wxWidgets library using Open Watcom

This page will describe how to create DLL versions of wxWidgets 2.4.2 using Open Watcom.

For questions, you would contact me at lothar |dot| behrens |at| lollisoft |dot| de

Basically you need to modify makefile.wat, makewat.env, your main application and you need to add a define of WXUSINGDLL for your app to build properly.

Hope this helps some Open Watcom users :-)

Lothar

Changes in your application based on dynamic sample

 // OSX is defined for Mac OS X platform
 
 // Create a new application object
 
 #ifdef OSX
 IMPLEMENT_APP  (MyApp)
 #endif
 #ifdef LINUX
 #ifndef OSX
 IMPLEMENT_APP  (MyApp)
 #endif
 #endif
 
 #ifndef OSX
 #ifndef LINUX
 wxApp *wxCreateApp()
     {
         wxApp::CheckBuildOptions(wxBuildOptions());
         return new MyApp;
     }
 
 //wxAppInitializer wxTheAppInitializer((wxAppInitializerFunction) &wxCreateApp);
 MyApp& wxGetApp() { return *(MyApp *)wxTheApp; }
 
 wxApp* _app = NULL;
 
 int PASCAL WinMain(HINSTANCE hInstance,
                    HINSTANCE hPrevInstance,
                    LPSTR lpCmdLine,
                    int nCmdShow)
 {
     //wxAppInitializer wxTheAppInitializer((wxAppInitializerFunction) wxCreateApp);
 
     MyApp::SetInitializerFunction(wxCreateApp);
 
     return wxEntry((WXHINSTANCE) hInstance, (WXHINSTANCE) hPrevInstance, lpCmdLine, nCmdShow);
 }
 #endif
 #endif


Additions in makewat.env (directory src/)

<pre>

  1. Set the default

!ifndef MAKEDLL MAKEDLL=1 !endif

!ifeq MAKEDLL 1 MAKEDLL_FLAGS= /D_WINDLL /DWXMAKINGDLL !else MAKEDLL_FLAGS= !endif </pre>

Additions and modifications in makefile.wat (directory src/msw)

<pre>

  1. Default make wxWidgets dll

MAKEDLL=1

!include ..\makewat.env

LIBTARGET = $(WXDIR)\lib\$(LIBNAME).lib DLLTARGET = $(WXDIR)\lib\$(LIBNAME).dll

  1. Replace line beginning with all: to

!ifeq MAKEDLL 1 all: $(EXTRATARGETS) alldll !endif

!ifeq MAKEDLL 0 all: $(SETUP_H) $(OUTPUTDIR) $(OBJECTS) $(LIBTARGET) $(EXTRATARGETS) .SYMBOLIC !endif

alldll: $(SETUP_H) $(OUTPUTDIR) $(OBJECTS) $(DLLTARGET) $(EXTRATARGETS) .SYMBOLIC

  1. After the definition how to make LIBTARGET add these lines:
  1. These line has an absolute path !

WATCOMLIBS=$(WXDIR)\..\..\Tools\watcom\lib386\nt

  1. DLLTARGET

$(DLLTARGET) : $(OBJECTS)

   %create $(LBCFILE)
   %append $(LBCFILE) NAME $^@
   @for %i in ( $(OBJECTS) ) do @%append $(LBCFILE) FIL %i
   %append $(LBCFILE) LIBR $(WXDIR)\lib\png$(WATCOM_SUFFIX).lib
   %append $(LBCFILE) LIBR $(WXDIR)\lib\jpeg$(WATCOM_SUFFIX).lib
   %append $(LBCFILE) LIBR $(WXDIR)\lib\tiff$(WATCOM_SUFFIX).lib 
   %append $(LBCFILE) LIBR $(WXDIR)\lib\regex$(WATCOM_SUFFIX).lib 
   %append $(LBCFILE) LIBR $(WXDIR)\lib\zlib$(WATCOM_SUFFIX).lib
   %append $(LBCFILE) LIBR $(WATCOMLIBS)\kernel32.lib
   %append $(LBCFILE) LIBR $(WATCOMLIBS)\user32.lib
   %append $(LBCFILE) LIBR $(WATCOMLIBS)\gdi32.lib
   %append $(LBCFILE) LIBR $(WATCOMLIBS)\comdlg32.lib
   %append $(LBCFILE) LIBR $(WATCOMLIBS)\comctl32.lib
   %append $(LBCFILE) LIBR $(WATCOMLIBS)\advapi32.lib
   %append $(LBCFILE) LIBR $(WATCOMLIBS)\shell32.lib
   %append $(LBCFILE) LIBR $(WATCOMLIBS)\ole32.lib
   %append $(LBCFILE) LIBR $(WATCOMLIBS)\oleaut32.lib
   %append $(LBCFILE) LIBR $(WATCOMLIBS)\uuid.lib
   %append $(LBCFILE) LIBR $(WATCOMLIBS)\rpcrt4.lib
   %append $(LBCFILE) LIBR $(WATCOMLIBS)\wsock32.lib
   %append $(LBCFILE) LIBR $(WATCOMLIBS)\winmm.lib
   wlink op q op symf d dwarf SYS nt_dll op m op maxe=25 op q op symf d dwarf @$(LBCFILE)
   wlib -q -n -b $(LIBTARGET) +$^@

</pre>