2

I need to link the Allegro Game Development Library from my Makefile. When I do this, the compiler returns:

Undefinied Reference < Function Name >.
Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
Bruno Alano
  • 643
  • 1
  • 11
  • 21

1 Answers1

4

Before trying to embed the compilation line into the Makefile, make sure you understand how to do it the command line, and more important, make sure it works:

g++ hello.cpp -o hello -I/usr/include/allegro5 -L/usr/lib -lallegro

Then, a simple Makefile to compile hello.cpp could be:

CXX=g++
CFLAGS=
LDFLAGS=-L/usr/lib -lallegro
INCLUDE=-I. -I/usr/include/allegro5

OBJS=hello.o
OUT=hello

all: hello_rule

clean:
        rm -rf *.o hello

hello_rule: $(OBJS)
        $(CXX) $(OBJS) -o $(OUT) $(INCLUDE) $(CFLAGS) $(LDFLAGS)
Community
  • 1
  • 1
karlphillip
  • 92,053
  • 36
  • 243
  • 426
  • For Windows, you would have to execute: `gcc src/main.c -o hello -I/include -L/lib -lallegro-5.0.3-md` – karlphillip Jul 03 '11 at 21:42
  • Or you can link against liballegro-5.0.3-monolith-md, which is the same as linking against Allegro and all of its addons. – Matthew Jul 04 '11 at 01:13