Intro | MinGW with Code::Blocks setup | Your First Program | Adding PDCurses | Adding Allegro | Adding SDL
External libraries are the reason why C/C++ remains, after all of its years, current. There is a base level of functions and libraries that come standard with any C/C++ installation, but those do little more than handle basic Input/output and a few cool routines. If you want to really do the cool, state of the art, things that you see in modern games, you’ll need to extend C/C++. However, it’s not always easy, especially the first time. That’s why I’ve chosen PDCurses. Curses programs are not much bigger than standard C/C++ program, but have the potential to be much cooler. However, PDCurses doesn’t always install easy, so it’s an excellent example of what you may have to go through. This tutorial assumes you are using Code::Blocks and that you installed it in C:\CodeBlocks as shown in the last tutorial.
Installing PDCurses
First a short video:
From the video the steps are:
- Go to http://pdcurses.sourceforge.net
- On the left click Downloads, click on the Download button next to the latest PDCurses release, then download the .zip file.
- Extract the .zip file to
c:\codeblocks\pdcursesand open up the folder. - Copy and paste the contents of the address bar for later.
- Under the start menu choose Programs->Accessories->Command Prompt
- Type the following being sure to press the right-mouse button and select Paste when it says to:
- Open Code::Blocks.
- Start a new project. Make it a console application.
- Choose C for your language.
- Name your project. I recommend "CursesHello"
- Go to the Management pane, under the Projects tab expand your sources and open main.c.
- Clear out what's there and paste the following code:
- Before this will compile we need to point the compiler to the library we created earlier.
- In the menu choose Project->Build Options.
- Click on the Linker Settings tab.
- Click the Add button. Point it to
c:\codeblocks\pdcurses\win32\pdcurses.a - In the windows that pops up choose "No" to keeping this a relative path.
- Click on Search Directories tab.
- Add
c:\codeblocks\pdcursesandc:\codeblocks\pdcurses\win32to all three tabs under the Search Directories tab; Compiler, Linker and Resource Compiler. - Click the OK button.
- Build and run the program.
cd\
cls
set PDCURSES_SRCDIR= (right-mouse click->Paste)
path=c:\codeblocks\mingw\bin
cd (right-mouse click->Paste)
cd win32
mingw32-make -f mingwin32.mak
exit
#include <curses.h>
int main() {
initscr(); /* Start curses mode */
printw("Hello World!"); /* Print Hello World */
refresh(); /* Print it on to the real screen */
getch(); /* Wait for user input */
endwin(); /* End curses mode */
return 0;
}
Congratulations, you've just built, installed, and used the external PDCurses library.
Installing Allegro
At this point there exists several excellent resources online. For Allegro theĀ Allegro wiki has all the information you need to get started. After PDCurses setting this one up is a breeze.
And when you're done with that here's a hello world program for you to test that you've done things right with.
At this point you may become aware that our hello world programs are getting bigger. Get used to it. The cooler they get, the bigger they get.
Simple Direct-Media Layer (SDL)
Lazyfoo's tutorials are perhaps the best SDL resources on the net bar none. He even has a picturesque tutorial on setting up SDL for Code::Blocks that's even easier than all the others.

