user_loser
user_loser

Reputation: 871

How to compile Allegro 5 program with GCC using only C programming language

stackoverflow, et. al.,

I just installed Allegro 5 on my Ubuntu machine and I see some source code for this game development tool, but I do not see specific instructions for how to compile it.

For C programs I use gcc on the terminal.

My questions are:

Thank-you for reading. I have read two c books so I am not a complete noob, but I have the struggles...

All the best,

user2085446

Upvotes: 0

Views: 5961

Answers (1)

us2012
us2012

Reputation: 16253

Okay, let's put this into an answer:

If your program just consists of a single .c file, you can run gcc from the path the file is in. However, in general there's nothing wrong with invoking gcc from anywhere else as long as you get the paths right.

For linking with external libraries, you need -lmylibrary options in the compiler command, e.g. -lfreetype for the freetype library and so on.

Now, this can get a bit complicated when your libraries depend on other libraries etc. That's what the pkg-config tool is for.

When you look at the allegro wiki page, you will see the following sample command:

gcc [source file(s)] -o [output] `pkg-config --libs allegro-5.0`

The pkg-config bit will resolve the relevant -l options for you.

Upvotes: 3

Related Questions