Free Download Dav C++
For Download Click Here
Dev-C++ Setup Guide
Please notice that the tutorial below is quite old and
that while it is quite possible to use wxWidgets with both Dev-C++ versions 4
and 5 by following these instructions, it might interest the reader to know
that there now exists an enhanced version of Dev-C++ including wxWidgets
support called wxDev-C++.
This is an actively supported, more updated release of Dev-C++ version 5,
having an integrated form designer, with wxWidgets libraries, program
templates and examples already present within the distribution.
by Julian Smart, September 2002Updated April 2003
This page helps you set up Dev-C++ for wxWidgets. There are instructions for using version 4 (manual setup) and version 5 (DevPak setup).
DevPak Setup using Dev-C++ 5
Thanks to Karl Penzhorn for this information.- Download Dev-C++ (at least 4.9.8, which is a version 5 beta) from here.
- Download the wxWidgets 2.4.0 and imagelib DevPaks from here.
- Install Dev-C++ (self installing .exe).
- Install imagelib FIRST, just by double clicking on the downloaded DevPak.
- Now the same for the wxWidgets DevPak.
- There's one mistake in the templates, easy to fix. Note: this has now
been fixed in the latest DevPak for wxWidgets (2003-05-16).
- Open dev-cpp\Templates\WxWindows.template in a text editor (notepad) and go to the [Project] section.
- Copy the line Compiler=--pipe -D...etc and paste just below.
- Change pasted line to CppCompiler=--pipe -D.... etc and save the file.
- Now, load up Dev-C++. File->New->Project GUI->wxWidgets. Save in a directory. Compile. Should work perfectly.
VC++ Project File Import with Dev-C++ 5
Another method is to just import the VC++ project file (.dsp) from the wxWidgets src directory, add appropriate include and resource directories in the converted .dev project, copy and change setup.h, then press F9.Manual Setup Using Dev-C++ 4
Compiling, Running and Debugging Your Program
Also, if you use the wxWidgets DevPak, you can discount these instructions: instead, all you have to do is open the Check For Packages/Updates under 'Tools' and download the wxWidgets DevPak. It auto-installs. Then you simply say New/Project/GUI/wxWidgets and you've got a basic wxWidgets app that compiles. (Note: sometimes it doesn't compile straight away because the DevPak forgets to put the command line options for the compiler under 'C++ compiler', only 'Compiler'. just simply go into the compiler options and copy, paste.)
What can I do with Dev-C++?
Dev-C++ is basically a GUI wrapper around the MinGW C++ compiler. MinGW is itself a cut-down version of the Cygwin compiler, without the POSIX compatibility layer.Dev-C++ allows you to create projects, edit source files, specify switches to pass to the compiler and linker, and then compile and link your program without having to drop down to the command line and type 'make' as you would otherwise do with MinGW.
What about debugging? Well, Dev-C++ does come with a console-based version of gdb, which most users would find pretty lame. Instead, you can download Insight, which is a slightly clunky user interface built on top of gdb. But it's better than nothing, and becoming familiar with a debugger is essential if you're serious about writing interesting C++ applications.
Installing the Tools
- Download Dev-C++ 4 from here.
- Download Insight and unzip it into your Dev-C++ directory.
- There is a bug in the MinGW header files distributed with Dev-C++ 4,
which affects wxWidgets. Without the fix you will get a link error
referring to the symbol EnumDAdvise__11IDataObjectPP13IEnumSTATDATA@8.
Edit the file include/objidl.h at line 663 and add a missing
PURE keyword. Change it from:
STDMETHOD(EnumDAdvise)(THIS_ IEnumSTATDATA**);
to:
STDMETHOD(EnumDAdvise)(THIS_ IEnumSTATDATA**) PURE;
- Download wxDevCPPTemplate.zip and unzip into the Dev-C++ Templates directory.
- Download and install wxWidgets for Windows, from the downloads page.
- Download and install extra.zip, a small collection of Unix-like utilities that you need when compiling wxWidgets. Unzip this to a directory such c:\apps\extra. A bin directory will be created under this.
- Set your HOME environment variable to a directory you can call home, for
example c:\home. You can set the environment variable from the Control
Panel/System applet in recent versions of Windows. Make a new file
called c:\home\gdb.ini with contents similar to the following:
dir /cygdrive/c/wx2/include/wx:/cygdrive/c/wx2/include/wx/msw:/cygdrive/c/wx2/include/wx/generic:/cygdrive/c/wx2/src/common:/cygdrive/c/wx2/src/msw:/cygdrive/c/wx2/src/generic
This tells gdb (and in particular Insight) where to find source files. Change the directory according to where wxWidgets is on your system. The notation /cygdrive/c is equivalent to c: (gdb needs it to be this way).
- To compile wxWidgets for Dev-C++/MinGW, edit src/makeg95.env in
your wxWidgets distribution, setting MINGW32 to 1 and
MINGW32VERSION to 2.95. Edit your PATH to include the Dev-C++
bin directory and also the extras bin directory (to pick up 'rm', 'make'
and so on), set WXWIN, and then build wxWidgets. For example:
set PATH=c:\apps\Dev-C++\bin;c:\apps\extras\bin;%PATH% set WXWIN=c:\wx2 cd c:\wx2\src\msw make -f makefile.g95 all
This will build a debugging version of wxWidgets. Please note that you can't currently use the 'configure' method of compilation since there is a conflict between the version of MinGW distributed with Dev-C++, and the MSYS package that you need to install to run configure (you get a cygwin1.dll error). Perhaps someone can work around that limitation.
If you wish to use MSYS instead of extras.zip, please add the line OSTYPE=msys to makeg95.env, and in src/msw/makefile.g95 replace the line:
$(COPY) $(WXDIR)/include/wx/msw/setup.h $@
with:
$(COPY) $(WXDIR)/include/wx/msw/setup.h $(subst $(BACKSLASH),/,$@)
before building, to ensure that the setup.h gets copied to the correct location. Note that you should still invoke makefile.g95 from DOS and not from MSYS's shell, because of the Cygwin DLL conflict.
Creating a Project in Dev-C++
Let's assume wxWidgets is in c:\wx2 (substitute your own install path in the instructions below as appropriate).Click on File|New Project..., click on the GUI Toolkits tab, and then select wxWidgets. Click OK.
You are presented with a file dialog: create a new directory for your project with the Create New Folder tool, type the folder name such as myproject, navigate into the folder and save the project as e.g. myproject.
Bring up the Project Options dialog (Project menu, Project options command). Some of these options will have been filled in already by the template, but some won't. If they have been filled in, check that the directories are correct for you.
- Add these options to the Further object files or linker options
field:
-lwxmswd -lcomdlg32 -luser32 -lgdi32 -lole32 -lwsock32 -lcomctl32 -lctl3d32 -lgcc -lstdc++ -lshell32 -loleaut32 -ladvapi32 -luuid -Lc:\wx2\lib
- Add these options to the Extra compiler options field:
-fno-rtti -fno-exceptions -fno-pcc-struct-return -fstrict-aliasing -Wall -fvtable-thunks -D__WXMSW__ -D__GNUWIN32__ -DWINVER=0x400 -D__WIN95__ -DSTRICT -D__WXDEBUG__
- Add these options to the Extra include directories field:
c:\wx2\include;c:\wx2\lib\mswd
- Check these two options in the Project type box: Compile C++ project, Do not create a console.
- Click on OK.
- Click on the Linker tab and check Generate debugging information and Compile for Win32 (no console).
- Click on OK.
Compiling, Running and Debugging Your Program
Hit the Compile Project button to compile your program, and click on Continue when it has finished. With luck, all should be well and there should be no compile or linker errors. If there are linker errors, there is probably a typo in your paths - go back and check the preceding steps.Now hit the Run Project button. A window should appear.
To debug your program, stop running it in Dev-C++ and click on the Debug Project button. If you installed Insight correctly, the Insight window will come up as per the picture on the right, showing a rather arbitrary source file. Select the source file you're interested in from the combobox at the bottom left of the main window, and click on the left of the line you wish execution to stop at: say, Show(TRUE) in MainApp::OnInit.
Click on the Run icon, and the program should run until your breakpoint. You can now use the Step, Next, Finish, Continue etc. to step through your program. Bring up the local variables or watch windows to look at data in your program.
The gdb Console is useful for adding extra source directories, for example, and other commands you wish to feed to gdb directly. Dev-C++ comes with a gdb help file that you may wish to peruse. Insight's online help is pretty horrible to view.
No comments:
Post a Comment