Problems compiling allegro game. Probably a linking error. Libraries?
miner_tom

Hi,

I am new to game programming with Allegro.

I have downloaded a very popular game program called "blasteroids". When I try to use the make file to compile the program I get an error that very much seems related to libraries:

"undefined reference to symbol 'cos@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSL missing from command line"

I have done research online and found that this problem is usually due to the order in which libraries are presented to gcc for linking.

I went looking for the allegro libraries, where the makefile suggests, which is /usr/lib and I found no .so files specifically related to allegro.

Is there something wrong with my installation of allegro?

Thank You
Tom

Peter Hull

Do you mean 'DSO missing from command line'?

Can you post the linker command line? (or, where is the source for Blasteroids that you're using?)

miner_tom

Hi, of course you are correct. The error is

"undefined reference to symbol 'cos@@GLIBC_2.2.5"
"/lib64/libm.so.6: error adding symbols: DSO missing from command line"

The linking section from the Makefile is as follows:

CXX=gcc
CFLAGS=-Wall -g
LDFLAGS=-L/usr/lib -lallegro -lallegro_primitives -lallegro_audio -lallegro_acodec -lallegro_font -lallegro_ttf -lallegro_main
LDFLAGS1=-L/usr/lib -lallegro -lallegro_primitives
INCLUDE=-I. -I/usr/include/allegro5

Thank You
Tom

Peter Hull

It might be as simple as adding '-lm' to the definition of LDFLAGS, i.e.

LDFLAGS=-L/usr/lib -lallegro -lallegro_primitives -lallegro_audio -lallegro_acodec -lallegro_font -lallegro_ttf -lallegro_main -lm

Try it!

miner_tom

OMG! That was amazing!

I had tried that but I had added the -lm to the line of the LDFLAGS(1) variable:

LDFLAGS1=-L/usr/lib -lallegro -lallegro_primitives -lm

That did not work. However, adding the -lm after the LDFLAGS variable DID work.

Interesting. Can you tell me why, just for my own education?

Thank You
Tom

Peter Hull

I googled for 'blasteroid allegro' and it turns out there are 2 or 3 games with that name, but using the bit of the makefile you posted, I guessed it was this one:
https://github.com/onesuper/blasteroid

... and from looking at the makefile I saw that LDFLAGS is used in linking the executable

blasteroid: $(OBJS)
	$(CXX) $(OBJS) -o $(OUT) $(INCLUDE) $(CFLAGS) $(LDFLAGS)

and LDFLAGS1 is only used for some kind of test program and so is irrelevant

test_collision: test_collision.o utils.o bbox.o
	$(CXX) test_collision.o utils.o bbox.o -o test_collision $(INCLUDE) $(CFLAGS) $(LDFLAGS1)

I've done the same thing myself (many times!) - for some reason, not all GCCs need you to put -lm in the linker flags, and you only find out it's missing when you try to build on another system.

Thread #615684. Printed from Allegro.cc