Hi,
i'm new to allegro 5 and i'm having some problems to add text to my program.
There is the part of mt code that is using the allegro addons:
when i compile it returns this weird mistakes:
Ive already done some programs with allegro5, but qhen i tried the addons it did not compiled.
I looked into the libraries of the allegro folder, but did not find any reference to the allegro_ttf.h. Do i have to download it separately?
Could someone help me?
You might be missing FreeType or another dependency, what did cmake say you were missing?
You need to link with the addon libraries.
i think i partially solved the problem. I linked the libraries, but now the gcc accuses a lot of error in the allegro_font.h.
for example:
someone know what is wrong?
You just need to link to the addon libraries, similar to how you link to the allegro library itself.
Well, i linked it.
But the strange problems i said before happened.
Are you including allegro_font.h before or after allegro5.h?
after, does it make any diference?
from my make file
LIB = serial.c CreateControl.c Getch.c CreateMath.c LibGa.c allegro5.h allegro.h allegro_font.h allegro_ttf.h font.h
but the compiler is accusing errors in the library. =/
LIB = serial.c CreateControl.c Getch.c CreateMath.c LibGa.c allegro5.h allegro.h allegro_font.h allegro_ttf.h font.h
Don't do that. You don't want to compile headers. You need to #include <headernamehere> them in your source (.c) files.
I'm including the libraries on my ~.c file, and they are after allegro5.h.
but when i try to compile gcc accuses al_init_font_addon() and al_init_ttf_addon() not to be defined.
ut when i try to compile gcc accuses al_init_font_addon() and al_init_ttf_addon() not to be defined.
Please show how you're compiling, and your source file that uses those functions.
This is the part of the code i'm trying to use allegro font and ttf addons.
this is my Makefile.
and the error is that the compiler do not find the definitions to al_init_font_addon; al_init_ttf addon and al_load_ttf_font("automati.ttf",72,0 ).
the full compiling log
Try:
`pkg-config --libs allegro-5.0 allegro_ttf-5.0`
If that's not enough: (from one of my makefiles)
`pkg-config --libs allegro-5.0 allegro_ttf-5.0 allegro_image-5.0 allegro_primitives-5.0`
g++ -g -Wall -W -DHAVE_CONFIG_H -I../common/include -I../libcwiid -g -Wall -I/addons/font -I/addons/ttf -lcwiid serial.c CreateControl.c Getch.c CreateMath.c LibGa.c allegro5.h allegro.h -o Wiimba Wiimba_03.o -lgcc -lm -lncurses `pkg-config --libs allegro-5.0`
Don't link with header files. You #include them in your source code to make declarations in them visible to functions within that source file.
As pointed out here.
Thank you,
the Arthur Kalliokoski's solution worked.
Perhaps, i'm having problems to load a ttf file. The ttf is in the same directory as my ~.c file and executable. But when it try to load, it gets a segfault.
Just to have my font file in the same directory should work? Or i have to do any configuration, or add any library?
=)
This should help
Thx,
but my ttf file is not even loading. It get a seg fault and returns nothing.
In other words, you're already doing
font = al_load_ttf_font("automati.ttf",72,0 ); if(!font) { some_error_msg(); exit(1); }
I've had it crash so bad it locked up the entire machine if the font was big enough with a point size 200+. (?) It was crashing the display driver.
Yes, i've already done that.
but when i reach the part of the code that uses the ttf loading, it Segfaults =\
Could it be a problem with the *.ttf font? Any ideas?
I've tried this as well:
and got:
i'm using ubuntu 10.10.
Thx