Allegro.cc - Online Community

Allegro.cc Forums » Installation, Setup & Configuration » How do I use Allegro?

This thread is locked; no one can reply to it. rss feed Print
How do I use Allegro?
xix131
Member #16,556
September 2016

Hi,
I'm very new to game programming and have no idea what I'm doing so far.

I simply want to get started in Allegro by testing to see if things are working. I want to make a simple program like on https://wiki.allegro.cc/index.php?title=Allegro_5_Tutorial/Displays to test it out. I have simply copy-pasted it out and here is my problem.

I am familiar with very basic C compiling in the command line. I know how to code python, c and c# on a basic level. I am on a Mac. I usually run make ___.c and understand simple use of gcc and ./outputObject . However, already on the first line of my program (probably the most crucial line), running gcc I get the error that
'allegro5/allegro.h' file not found

I had the file called al.c, ran gcc al.c and gave that error

I tried to do the best I could to set up Allegro but all I know is (I think) I have installed the library files in my usr/local/lib directory.

tl;dr I'm stuck trying to compile my first program. What do I need to fix?

Thanks in advance for any help <3

Audric
Member #907
January 2001

Hi and welcome!
From the message, the missing part is the header file. Installing allegro (or any C library) for a GCC compiler involves two types of files, the headers (*.h) go in an "include" library, and the library's linkable code (*.a, *.so) go in an "lib" directory.

I'm not an OSX user, but you can check if you have a /usr/local/include directory.

If you don't quickly find your answers, you may want to remove the files that you put, then try the following method:
https://wiki.allegro.cc/index.php?title=Getting_Started#Mac_OS

xix131
Member #16,556
September 2016

Hi again,
Thank you for the quick response.

I think I have sorted out a few things and have ran into a new problem. I think this one is easier to solve (perhaps).

I try compiling using :

and now I am no longer getting errors about including the allegro.h file. But, now I am getting errors in linking:

Quote:

Undefined symbols for architecture x86_64:
"_al_clear_to_color", referenced from:
__al_mangled_main in newal-cb23e2.o
"_al_create_display", referenced from:
__al_mangled_main in newal-cb23e2.o
"_al_destroy_display", referenced from:
__al_mangled_main in newal-cb23e2.o
"_al_flip_display", referenced from:
__al_mangled_main in newal-cb23e2.o
"_al_install_system", referenced from:
__al_mangled_main in newal-cb23e2.o
"_al_map_rgb", referenced from:
__al_mangled_main in newal-cb23e2.o
"_al_rest", referenced from:
__al_mangled_main in newal-cb23e2.o
"_main", referenced from:
implicit entry/start for main executable
(maybe you meant: __al_mangled_main)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

What have I done and how do I fix this?

Audric
Member #907
January 2001

I think it's because you didn't link allegro_main in addition to allegro
See this: http://liballeg.org/a5docs/5.0.10/getting_started.html#the-main-function

Order of linking is important, so be sure to write -lallegro -lallegro_main

xix131
Member #16,556
September 2016

Hi, I think I am getting closer and closer. Still getting an error though,

Quote:

ld: library not found for -lallegro
clang: error: linker command failed with exit code 1 (use -v to see invocation)

What would cause this error??? ???

Audric
Member #907
January 2001

xix131 said:

(I think) I have installed the library files in my usr/local/lib directory.

What files (names) did you copy there ? Do they have the same extensions as what was already there ?
I'm asking because you could have picked files for mingw/windows or msvc/windows instead of the ones you need.

Go to: