Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Problems compiling an allegro program with g++

This thread is locked; no one can reply to it. rss feed Print
Problems compiling an allegro program with g++
Jorge Luis Rodríguez González
Member #16,669
May 2017

Hello, I have problems building an exampĺe from the command line with a Makefile using the g++ compiler. This is the Makefile:

#SelectExpand
1CXX = g++ -std=c++14 2 3#Ruta donde está aleph 4ALEPH = ~/Libraries/Aleph-w 5 6#Ruta dónde está instalada Allegro 7ALLEGRO = /usr/include/allegro5 8 9#Ruta dónde están los fuentes de Allegro 10ALLEGRO_SRC = ~/Libraries/allegro5 11 12#Coloque aquí las rutas de los sources 13SOURCES = 14 15#Coloque aquí las rutas de los headers 16HEADERS = 17 18#Coloque aquí el nombre de las fuentes 19NAME = example 20 21#Coloque aquí lo que usará 22CONFIG = `pkg-config --libs allegro-5.0 allegro_ttf-5.0 allegro_init-5.0 allegro_draw-5.0 allegro_image-5.0 allegro_color-5.0` 23 24#Warnings para el debbuging 25WARN = -Wall -Wextra -Wcast-align -Wno-sign-compare -Wno-write-strings -L $(ALLEGRO_SRC)-DEBUG/lib \ 26 -Wno-parentheses -Wno-invalid-source-encoding #-lallegro_audio-debug-static -lallegro_color-debug-static -lallegro-debug-static -lallegro_dialog-debug-static -lallegro_image-debug-static -lallegro_main-debug-static -lallegro_memfile-debug-static -lallegro_primitives-debug-static -lallegro_ttf-debug-static 27 28FLAGS = -DDEBUG -O0 -g $(WARN) $(HEADERS) $(SOURCES) 29 30OPT = -DNDEBUG -Ofast -D__extern_always_inline="extern __always_inline" -DNDEBUG -std=c++14 $(WARN) 31#Termina lo del debugging 32 33INCLUDE = -I. -I $(ALEPH) -I $(ALLEGRO) 34 35LIBS = -L $(ALEPH) -L $(ALLEGRO) -L $(ALLEGRO_SRC) \ 36 -lAleph -lc -lm -lgsl -lgslcblas -lgmp -lmpfr -lpthread -lreadline -L/usr/lib -lallegro -DALLEGRO_STATICLINK -DDEBUGMODE=1 -v -g -W -I $(ALLEGRO_SRC)/include -I $(ALLEGRO_SRC)/addons/acodec -I $(ALLEGRO_SRC)/addons/audio -I $(ALLEGRO_SRC)/addons/color -I $(ALLEGRO_SRC)/addons/font -I $(ALLEGRO_SRC)/addons/image -I $(ALLEGRO_SRC)/addons/main -I $(ALLEGRO_SRC)/addons/memfile -I $(ALLEGRO_SRC)/addons/native_dialog -I $(ALLEGRO_SRC)/addons/physfs -I $(ALLEGRO_SRC)/addons/primitives -I $(ALLEGRO_SRC)/addons/ttf -lstdc++ -lpng -lz -ljpeg -lm -lpthread -lSM -lICE -lX11 -lXext -lXcursor -lXinerama -lXrandr -lGL -lGLU -lopenal -lFLAC -logg -ldumb -lvorbisfile -lvorbis -logg -ldumb -lvorbisfile -lvorbis -lallegro_dialog -lallegro_ttf -Bsymbolic-functions -lallegro_primitives -lallegro_audio -lallegro_acodec -lallegro_font -lallegro_ttf -lallegro_main -lallegro_memfile -lallegro_physfs 37 38all: Program 39 40Program: $(NAME).C 41 $(CXX) $(FLAGS) $(INCLUDE) $(NAME).C -o $(NAME) $(CONFIG) $(LIBS) 42 43clean: 44 rm -fr $(NAME) *~

The Alpeh-w is a Algorithms, data structure and miscelaneous library, so you don't need to worry about it. My problem is with allegro. It gives me thsi error after trying to build the program:

#SelectExpand
1/home/egroj97/Code/Allegro/Allegr_Test/example.C:219: undefined reference to `al_init_image_addon'

Please, help

Eric Johnson
Member #14,841
January 2013
avatar

You're building an example manually? How did you install Allegro to begin with? The examples should have been built already.

Do this:

git clone https://github.com/liballeg/allegro5
cd allegro5
mkdir build
cd build
cmake ..
make
sudo make install
sudo ldconfig

That'll clone and build Allegro and its examples for you. You should then be able to view each of the compiled examples by navigating to allegro5/build/examples.

Edit
Is that an example that came with Allegro 5, or one that you found somewhere else? I do not think you need "5.0"; I think instead it should just be "5" when using pkg-config.

Elias
Member #358
May 2000

Let's first make sure you can build without a Makefile. Try this in a terminal:

gcc example.C `pkg-config --cflags --libs allegro-5.0 allegro_ttf-5.0 allegro_init-5.0 allegro_draw-5.0 allegro_image-5.0 allegro_color-5.0`

And paste the error you get.

--
"Either help out or stop whining" - Evert

Go to: