I'm trying to learn to use allegro. I'm using dev c++.
I get bunch of linker errors Saying:
[Linker error] undefined reference to `install_keyboard'
[Linker error] undefined reference to `set_gfx_mode'
[Linker error] undefined reference to `readkey'
and lots others
This is the code.
1 2 3 4 5 6 7 8 9 10 11
#include <allegro.h> // You must include the Allegro Header file
int main(int argc, char *argv)
allegro_init(); // Initialize Allegro
install_keyboard(); // Initialize keyboard routines
set_gfx_mode(GFX_AUTODETECT, 640,480,0,0); // Change our graphics mode to 640x480
readkey(); // Wait untill a key is pressed
return 0; // Exit with no errors
END_OF_MAIN() // This must be called right after the closing bracket of your MAIN function.
// It is Allegro specific.
as Stewbond says, you have to make sure you link to the allegro library (.lib) file. I'd strongly recommend you switch to Microsoft Visual C++ Express 2010, It is the most advanced compiler currently, doesn't have all the bugs that DevCPP does and also ITS FREE!. You can download it from here: http://www.microsoft.com/visualstudio/eng/downloads . Remeber, choose the EXPRESS one, not the professional because that version is not free. Believe me, I've worked with DevCpp before and I got a lot of errors I couldn't solve. Then I found out that my program was not wrong, but the compiler Was.