win32 F/OSS development - C/C++

C++ Logo via Blender

Assuming you've installed MinGW, you've got the compiler, assembler, linker and debugger installed to work with C and C++. Now we'll can add an IDE and some libraries including the oh-so-sweet Qt.

IDE - Dev-C++

First up is Dev-C++, an IDE that integrates well with MinGW. From the BloodshedSoftware download page, grab the Dev-C++, executable only version. Run the installer with defaults.

You'll need to point Dev-C++ to your MinGW install. Start it up and select 'Tools' -> 'Compiler Options'
Click on the 'Directories' Tab. The following are my settings:

Dev-C++ Settings 1
Dev-C++ Settings 2
Dev-C++ Settings 3
Dev-C++ Settings 4

Dev-C++ Package Update


You can get updates and additional library files (GTK shown here) by clicking on Tools -> Check for Updates/Packages


Toolkit - Qt

For Qt, hit the Open source Edition Download page and get qt-win-opensource-x.x.x-mingw.exe Run the installer; when prompted for the path to MinGW, use:

minGW install using QTs installer


C:\MinGW\

Library - SDL

SDL or Simple DirectMedia Layer is a multimedia library for C/C++ with bindings for just about every language. Look for the download link, then find the 'Development Libraries:'. Under the 'Win32:' entry find the Mingw32 download. You'll need to extract it to a temp directory, so you'll have something like c:\temp\SDL-x.x.x\ Now you'll need to move the files so that MinGW can find them.

  1. Move all the .h files from the \include subdir to an SDL subfolder in the MinGW\include directory. For my setup it's C:\MinGW\include\SDL\
  2. Copy all the .a files from the \lib subdir to the MinGW \lib folder. For me this is C:\MinGW\lib\
  3. Copy the files from the \bin subdir to your \msys\bin\ folder. Mine is C:\msys\1.0\bin\
  4. Copy the file SDL.dll from the \bin subfolder to your path. I use a c:\bin\ folder, but anything in the path (c:\windows\system32\ is a common choice) will work

Now to test. Open a command prompt and browse to the \test subfolder of the SDL temp dir. You'll need to point to the SDL.h in it's subdir. Edit testwin.c as follows:

#include "SDL.h"
     to:
#include "SDL/SDL.h"

The following will compile the testwin.c and link the SDL files producing a happy a.exe

gcc testwin.c -lmingw32 -lSDLmain -lSDL -mwindows



Documentation




Code Snippets

  • : Hello world. src





< < Back to Start >>