Dev-CPP Setup Guide

From WxWiki
Jump to: navigation, search

Dev-CPP Setup Guide

This page describes the steps I took in order to get Dev-Cpp to work with a homebuilt wxWidgets. I was using Dev-Cpp and wxWidgets 2.5 from CVS.

Preparing Dev-Cpp

Now you have Dev-Cpp installed, and you can happily program wxPrograms. However, the wxWidgets build is not tailored to your system, ESPECIALLY in the regard that you have a final build of the wxWidgets libraries. This is good for production releases of your applications, but not so good for development. I, for one, spend quite a bit of time debugging any applications I create.

So, now we've discovered that we really need to have a homebuilt version of wxWidgets, with debugging information made available to us. This is how I got involved in the making of this wiki page; there is surprisingly little information out there to describe the integration of Dev-Cpp with wxWidgets. Now that I'm finished, perhaps it wasn't really all that hard.

Anyhow, on to building our own copy of wxWidgets.

Building your own wxWidgets Library

Download MSYS and compile wxWidgets as described in Compiling wxWidgets with MSYS-MinGW

At this point, you should have a working 'debug' version of wxWidgets. Now we need to integrate it with Dev-Cpp.

Integrating Dev-Cpp with the new Library

  • Run Dev-Cpp.
  • Open a wxWidgets project, and open the project options dialog.
  • On the Parameters tab, enter the following for your c++ compiler options. ( -D__WXDEBUG__ -D__WXMSW__ -g -O0 -mthreads -Wall )
  • On the Parameters tab, enter the following for your linker options. ( -mthreads -Wl,--subsystem,windows -mwindows -lwx_mswd-2.5 -lwxjpegd -lwxpngd -lwxzlibd -mthreads -lrpcrt4 -loleaut32 -lole32 -luuid -lwinspool -lwinmm -lshell32 -lcomctl32 -lcomdlg32 -lctl3d32 -ladvapi32 -lwsock32 -lgdi32 -ltiff ) Note the library lwx_mswd-2.5. That will likely change depending on how your configure your build, and which version you are building, so just find it in the build lib folder, and grab the right name. ( libwx_mswd-2.5.a --> lwx_msw-2.5 )
  • On the Directories|Library tab, enter the lib directory for your special build. ( mine is C:\wx\msw-debug\lib )
  • On the Directories|Include tab, enter at least the following, per your own build :
    • ( C:\wx\msw-debug\lib\wx\include\mswd-2.5 )
    • ( C:\wx\include ) Note this is the MAIN include for your distribution, and not your special build.
  • Notes:
    • You may need to go into Tools|Compiler Options|Programs and change make.exe to mingw32-make.exe
    • If you get an error about "duplicate sections" you probably have an old copy of one of the libs floating around.


Now, that should be all that is needed. Your Dev-Cpp ought to work with your new build now. To be careful, you might want to dive into the Dev-Cpp directories, and remove the earlier installed copy of wx and its include folder.

I hope this page is of some benefit to somebody. It took me a very long time to get everything working correctly.


Common problems

Undefined reference to: .... while linking

If you have added all the neccesary library files to the linker options and there are still unresolved references you might have come around a rather strange "feature" of gcc (g++ 3.2): it's picky about the order you place the libraries. If you are using the xrc resource system the wxxrc library should come first. Then comes wxmsw and then the rest of the (wx)libraries you use. Set the following as linker settings and all should work fine:

-mwindows -Wl,--subsystem,windows -mwindows -lwxxrc -lwxmsw -lstdc++ -lgcc -lodbc32 -lwsock32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lctl3d32 -ladvapi32 -lopengl32 -lglu32 -lole32 -loleaut32 -luuid

Undefined reference to: png_blablabl while linking

If you're using wx/image.h (and maybe other things), you need to add the following libraries to the project settings as linker options:

-lpng -ltiff -ljpeg -lzlib

Cannot find -lwxmsw24

Maybe the library file is called slightly different. Look into the lib/ directories for a file called something like 'libwxmsw.a'.

Cannot find resource file

If you want to use wxWidgets resources (as for example the examples do), you need to add the '\dev-cpp\wx\include' (from the top of my head is that the correct path?) directory to the 'resource file directories' in the project settings.

File not found during make

If making fails with something like:

 process_begin: CreateProcess((null), D:Dev-C++Binmake -C ../../src/regex -f 
 file.g95 WXDIR=../.. WXWIN=../.., ...) failed.
 make (e=2): Le fichier specifu est introuvable

(translation: "the specified file cannot be found")

you're either:

  • not using the correct 'make' program: you should use MSYS make.
  • making a mistake in the path to the 'extra tools'
  • not having cp.exe installed

Solution for the latter:

- Download from - Copy UnxUtils\usr\local\wbin\cp.exe to Dev-Cpp\bin\cp.exe

Dev-CPP Alternate Setup Guide

Dev-C++ is a nice Free IDE for Windows that works quite well with wxWidgets. See their website here

There is a binary package available in devpak (Dev-Cpp package format) available here, don't get the version from vUpdate (it is old). You need to install the newest (beta) version of devc++, but generally, it's worth it.

If you would prefer to build wxWidgets from the sources (recommended for those who can) download 2.4.0 and follow the MinGW build instructions in docs/msw/install.txt

See also: