After much frustration of trying to figure it out on my own, I am finally ready to admit that I need help. Does anyone know how to compile allegro 5? (or better yet have a precompiled version I could get my hands on)

I have tried many tutorials and none of them work.

Thanks in advance

Recommended Answers

All 33 Replies

Is this an open source thing that we can download and try to compile? If so, please post a link.

Dave

It is yes. You should be able to find it here.

What platform are you on (linux or windows)?

Windows Vista (64 bit) using Dev-C++.

Dev-C++ starts getting dated, use the newest MinGW-compiler(s) instead ...
Edit:: Actually there comes a document with the distribution which describes the whole process ...
Edit:: Look at this link (STEP 1) to find more information on how to install the MinGW-compiler

Great! I have the compiler! now what?

Great! I have the compiler! now what?

(download the zip-file)

Now you read the instructions which came with the allegro package, just keep on asking if you don't understand something :) ...

how do I change it to codeBlocks MinGW for the generator?

how do I change it to codeBlocks MinGW for the generator?

I don't understand what you mean with this ...

when I type cmake and then the path name it comes up with an error:

Cmake was unable to find a build program corresponding to "Visual studio 6".

I don't have VS6 which I think might be the problem. So I was trying to change it to CodeBlocks, which I do have.

You don't have to type the path name after cmake, cmake is used to generate the makefiles :) ...

Use: cmake -G "MinGW Makefiles" Edit:: I'm trying to precompile it for you ...

It's looking for a compiler called g++, but comes up with an error because it can't find it. I think the right one that really does exist is the gcc compiler. If so how do I tell it to use that one?

It's looking for a compiler called g++, but comes up with an error because it can't find it. I think the right one that really does exist is the gcc compiler. If so how do I tell it to use that one?

Did you set the MINGDIR and PATH environment variables correctly ?

I set them just how it said to in the post you linked in one of your first replies.

Wait... I may have found it. I let you know in a minute.

It's Working!

Now, will my projects port directly to this new version or will I have to change some function and #include names? (I'm coming from v.4.2) Also, will there be new things I have to add to my projects?

Will there be new things I have to add to my projects?

Check out the Allegro documentation and the changelog :) ...

OK I'm marking this thread as unsolved because I can't find anywhere how to set up allegro 5 (eg. which files to include, which functions have changed and which linker options to set). I'm trying to get it up and running with Code::Blocks and MinGW. Thanks in advance.

OK I'm marking this thread as unsolved because I can't find anywhere how to set up allegro 5 (eg. which files to include, which functions have changed and which linker options to set). I'm trying to get it up and running with Code::Blocks and MinGW. Thanks in advance.

Have you tried to compile your existing code ?

Litterally just from the homepage: http://www.talula.demon.co.uk/allegro/changes.html

For the API: http://alleg.sourceforge.net/a5docs/refman/index.html

Was it that difficult ?

Yes I tried to compile an existing program.

I also found both of those sites and neither of them told me what I need to know. Specifically which linker options to set.

Yes I tried to compile an existing program.

And did it compile or not :?:

I also found both of those sites and neither of them told me what I need to know. Specifically which linker options to set

The linker options are probably the same or am I wrong ?

Maybe you should take a look at the makefile of the 'demo.exe' program and see what options are specified there do let the program compile :) ...

I didn't think I needed to specifically state that it didn't compile. Allegro 5 didn't come with the linker .lib's that I used before so I'm assuming that they changed. I couldn't find anything useful in the makefile, but maybe that's because it's several hundred lines long.

> Did you try compiling a program in the same way as you did before?
> Did it work?

No it didn't. There are some new functions used that aren't present in previous versions.

No it didn't. There are some new functions used that aren't present in previous versions.

So because of some new functions you can't use the old ones anymore and it doesn't compile?
Can you post your compiler's output please ?

The compiler can't really tell me what's wrong, because I don't know which libraries to link to my projects. These libraries contain all the definitions for the functions used by allegro.

Also, an example of the changed functions is the one that you need to call before using any other allegro functions, allegro_init(), may have been changed to al_init(). I'm not sure though.

P.S. Sorry for not replying, I've been out of town for a while.

The compiler output from a test program is:

obj\Debug\hello1.o||In function `mangled_main':|
C:\Users\Owner\Desktop\test3\hello1.c|22|undefined reference to `al_install_system'|
C:\Users\Owner\Desktop\test3\hello1.c|23|undefined reference to `al_font_init'|
C:\Users\Owner\Desktop\test3\hello1.c|26|undefined reference to `al_create_display'|
C:\Users\Owner\Desktop\test3\hello1.c|34|undefined reference to `al_install_keyboard'|
C:\Users\Owner\Desktop\test3\hello1.c|41|undefined reference to `al_ttf_load_font'|
C:\Users\Owner\Desktop\test3\hello1.c|42|undefined reference to `al_ttf_load_font'|
C:\Users\Owner\Desktop\test3\hello1.c|49|undefined reference to `al_map_rgba_f'|
C:\Users\Owner\Desktop\test3\hello1.c|50|undefined reference to `al_set_blender'|
C:\Users\Owner\Desktop\test3\hello1.c|53|undefined reference to `al_font_textout'|
C:\Users\Owner\Desktop\test3\hello1.c|54|undefined reference to `al_font_textout'|
C:\Users\Owner\Desktop\test3\hello1.c|57|undefined reference to `al_flip_display'|
C:\Users\Owner\Desktop\test3\hello1.c|60|undefined reference to `al_create_event_queue'|
C:\Users\Owner\Desktop\test3\hello1.c|61|undefined reference to `al_get_keyboard'|
C:\Users\Owner\Desktop\test3\hello1.c|61|undefined reference to `al_register_event_source'|
C:\Users\Owner\Desktop\test3\hello1.c|68|undefined reference to `al_wait_for_event'|
||=== Build finished: 15 errors, 0 warnings ===|

The program's code is:

// hello1.c
// An introduction to keyboard input and text output

#include <allegro5/allegro5.h>
#include <allegro5/a5_font.h>
#include <allegro5/a5_ttf.h>
#include <stdio.h>

struct Data {
	ALLEGRO_FONT *f1, *f2;
	ALLEGRO_DISPLAY *display;
	ALLEGRO_EVENT_QUEUE *queue;

	ALLEGRO_COLOR bright_green;
} data;

const char *font_file = "times.ttf";


int main(int argc, char *argv[]) {
	// Initialize Allegro 5 and the font routines
	al_init();
	al_font_init();

	// Create a window to display things on: 640x480 pixels
	data.display = al_create_display(640, 480);
	if(!data.display) {
		printf("Error creating display.\n");
		return 1;
	}


	// Install the keyboard handler
	if(!al_install_keyboard()) {
		printf("Error installing keyboard.\n");
		return 1;
	}


	// Load a font
	data.f1 = al_ttf_load_font(font_file, 48, 0);
	data.f2 = al_ttf_load_font(font_file, -48, 0);
	if(!data.f1 || !data.f2) {
		printf("Error loading \"%s\".\n", font_file);
		return 1;
	}

	// Make and set a color to draw with
	data.bright_green = al_map_rgba_f(0.5, 1.0, 0.5, 1.0);
	al_set_blender(ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA, data.bright_green);

	// Draw a message to the backbuffer in the fonts we just loaded using the color we just set
	al_font_textout(data.f1, 10, 10, "Allegro 5 Rocks!", -1);
	al_font_textout(data.f2, 10, 60, "Allegro 5 Rocks!", -1);

	// Make the backbuffer visible
	al_flip_display();

	// Start the event queue to handle keyboard input
	data.queue = al_create_event_queue();
	al_register_event_source(data.queue, (ALLEGRO_EVENT_SOURCE*)al_get_keyboard());


	// Wait until the user presses escape
	ALLEGRO_EVENT event;
	while(1) {
		// Block until an event enters the queue
		al_wait_for_event(data.queue, &event);

		// If the key was escape, then break out of the loop
		if(event.type == ALLEGRO_EVENT_KEY_DOWN && event.keyboard.keycode == ALLEGRO_KEY_ESCAPE) break;
	}


	return 0;
}
END_OF_MAIN()

Again this is because I don't know which linker libraries to add

Again this is because I don't know which linker libraries to add

Well, you compiled allegro right? Just check out the directory of the library files (lib) and you'll see :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.