Installing WxWin Digital Mars C

From WxWiki
Jump to navigation Jump to search

You can use the free Digital Mars C++ (dmc) compiler to develop wxWidgets code on Windows. This guide will tell you the required steps to install the compiler and required libraries. It was tested with wxWidgets 2.8.4 and Digital Mars C++ 8.49. If you use a different version of wxWidgets adjust the version number in the steps outlined below accordingly.

Install DMC

  1. download Digital Mars C++
  2. unzip the archive into c:\dm
  3. download the Basic Utilities from the same page as in step 1
  4. unzip the archive into c:\ (the zip contains a \dm\ directory)
  5. download the STLport library from the page of step 1
  6. unzip the archive into c:\ (the STLport zip from Digitals Mars contains a \dm\ directory)

Now create a file named setvars.bat with the following content (you can store this file in c:\dm\):

SET WXWIDGETS=c:\dm\wxWidgets-2.8.4
SET PATH=c:\dm\bin;%PATH%
SET INCLUDE=%WXWIDGETS%\include;%WXWIDGETS%\lib\dmc_lib\mswd;%INCLUDE%
SET LIB=%WXWIDGETS%\lib\dmc_lib;%LIB%

When you want to compile with dmc you now open a new command window (for example via Start->Run->"cmd") and then run the batch file above. Alternatively you can alter your global environment variables.

Install wxWidgets

  1. download wxMSW
  2. install wxWidgets into c:\dm\wxWidgets-2.8.4
  3. run the setvars.bat in a command line window
  4. cd c:\dm\wxWidgets-2.8.4\build\msw
  5. compile with make -f makefile.dmc, this will build the debug version which you should use for developing your application.

Test wxWidgets

  1. cd c:\dm\wxWidgets-2.8.4\samples\minimal
  2. compile the example with make -f makefile.dmc
  3. run the application with dmc_mswd\minimal.exe

Compiling your own applications

Now everything should be set up to compile applications on the command line with dmc and wxWidgets. However when compiling your source code you may be hit by the default maximum memory limit of dmc which is set to 30MB. If the compiler aborts with Fatal error: out of memory use the -HP argument to raise the memory limit, for example -HP99.

If you like to develop with makefiles I recommend you install a win32 version of GNU make, which is more comfortable to work with than the make shipped with dmc. You should ren c:\dm\bin\make.exe c:\dm\bin\dmmake.exe and install GNU make from the GNUwin32 project. The following Makefile is an example to compile the minimal sample.

# GNU Makefile to build wxWidgets application with Digital Mars C++

EXE=	minimal.exe
SRC=	minimal.cpp
RC=	minimal.rc

CXXFLAGS+=-D__WXDEBUG__=1 -g -w- -Ae -Ar -HP99 # -5 -o
OBJ=	$(SRC:%.cpp=%.obj) $(RC:%.rc=%.res)
RM=	del
LD=	$(CXX)
WXVER=	28d
LIBS+=	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 odbc32.lib wsock32.lib \
	wxbase$(WXVER).lib wxmsw$(WXVER)_core.lib wxmsw$(WXVER)_adv.lib
RCC=	rcc
RCCFLAGS=-32 -I$(subst ;, -I,$(INCLUDE)) -I..

all:	$(EXE)

$(EXE):	$(OBJ)
	$(LD) $(LDFLAGS) -o $@ $^ $(LIBS)

	$(RM) *.obj *.map *.res *~ $(EXE)

%.obj:	%.cpp
	$(CXX) $(CXXFLAGS) -c -o $@ $<

%.res:	%.rc
	$(RCC) $< -o$@ $(RCCFLAGS)

To use this Makefile with your application you should modify the EXE, SRC, and RC variables and include your own filenames. If you want to build a release version of your application you have to remove the -D__WXDEBUG__=1 -g args from CXXFLAGS and add the -5 -o args to enable optimizations. Further remove the d from WXVER.