Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » How to call function al_draw_multiline_text?

This thread is locked; no one can reply to it. rss feed Print
How to call function al_draw_multiline_text?
thatrabbit
Member #18,225
August 2020

Hello. I am running latest version of Allegro.

I see this function in docs:

https://liballeg.org/a5docs/trunk/font.html#al_draw_multiline_text

In my code I have at least:

#SelectExpand
1#include <allegro5/allegro_font.h> 2#include <allegro5/allegro_ttf.h> 3... 4al_init_font_addon(); 5al_init_ttf_addon(); 6...

When I compile, I am told "undefined reference to <al_draw_multiline_text>".

How do I use that function?

I can use al_draw_text okay. If I can get built-in newlines that helps a lot.

kenmasters1976
Member #8,794
July 2007

Does ex_font_multiline from the Allegro examples work?.

RmBeer2
Member #16,660
April 2017
avatar

You also need to link their library. (-lallegro_font -lallegro_ttf)

🌈🌈🌈 🌟 BlackRook WebSite (Only valid from my installer) 🌟 C/C++ 🌟 GNU/Linux 🌟 IceCream/Cornet 🌟 🌈🌈🌈

Rm Beer for Emperor 2021! Rm Beer for Ruinous Slave Drained 2022! Rm Beer for Traveler From The Future Warning Not To Enter In 2023! Rm Beer are building a travel machine for Go Back from 2023! Rm Beer in an apocalyptic world burning hordes of Zombies in 2024!

LennyLen
Member #5,313
December 2004
avatar

RmBeer2 said:

You also need to link their library. (-lallegro_font -lallegro_ttf)

I think it's safe to assume he's linking correctly if al_draw_text() is working.

My low-tech suggestion - are you sure you spelled the function correctly?

bamccaig
Member #7,536
July 2006
avatar

Which version of Allegro do you have installed? Seems that function was added in 5.1.9. ??? If you spelled it correctly and al_draw_text works then too old of a distribution seems like the only explanation left. :P

Mark Oates
Member #1,146
March 2001
avatar

Also possible you may be using the wrong function signature, which can result in an undefined reference.

--
Visit CLUBCATT.com for cat shirts, cat mugs, puzzles, art and more <-- coupon code ALLEGRO4LIFE at checkout and get $3 off any order of 3 or more items!

AllegroFlare • AllegroFlare Docs • AllegroFlare GitHub

bamccaig
Member #7,536
July 2006
avatar

That's true, but only if he forward declared the signature himself. Otherwise, the compiler would choke before the linker was invoked. :-*

RmBeer2
Member #16,660
April 2017
avatar

What signature?? i get lost...

🌈🌈🌈 🌟 BlackRook WebSite (Only valid from my installer) 🌟 C/C++ 🌟 GNU/Linux 🌟 IceCream/Cornet 🌟 🌈🌈🌈

Rm Beer for Emperor 2021! Rm Beer for Ruinous Slave Drained 2022! Rm Beer for Traveler From The Future Warning Not To Enter In 2023! Rm Beer are building a travel machine for Go Back from 2023! Rm Beer in an apocalyptic world burning hordes of Zombies in 2024!

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

bamccaig
Member #7,536
July 2006
avatar

RmBeer2 said:

What signature?? i get lost...

f1.cpp#SelectExpand
1void f1(int * x) 2{ 3 *x *= 2; 4}

main.cpp#SelectExpand
1void f1(const char *); 2 3int main(int argc, char * argv[]) 4{ 5 f1("Hello, World!\n"); 6 7 return 0; 8}

g++ -Wall f1.cpp -c
g++ -Wall main.cpp -c
g++ -Wall f1.o main.o
main.o: In function `main':
main.cpp:(.text+0x17): undefined reference to `f1(char const*)'
collect2: error: ld returned 1 exit status

f1 is a real function, and it has been linked, but the signature doesn't match the one expected by main.o.

Interesting to note that C did not care at all. It compiled and linked without errors. Then it segfaulted at runtime. :-/

RmBeer2
Member #16,660
April 2017
avatar

f1.cpp: _Z2f1Pi
main.cpp: _Z2f1PKc

This's a signature? i see...

Saying they have different parameters looks less confusing. Although this is what makes C++ stackable with the same function name.

In that case he should show what is the source code, the compilation line and the compilation output. To be more sure.

🌈🌈🌈 🌟 BlackRook WebSite (Only valid from my installer) 🌟 C/C++ 🌟 GNU/Linux 🌟 IceCream/Cornet 🌟 🌈🌈🌈

Rm Beer for Emperor 2021! Rm Beer for Ruinous Slave Drained 2022! Rm Beer for Traveler From The Future Warning Not To Enter In 2023! Rm Beer are building a travel machine for Go Back from 2023! Rm Beer in an apocalyptic world burning hordes of Zombies in 2024!

Mark Oates
Member #1,146
March 2001
avatar

That's a great example, BAM.

--
Visit CLUBCATT.com for cat shirts, cat mugs, puzzles, art and more <-- coupon code ALLEGRO4LIFE at checkout and get $3 off any order of 3 or more items!

AllegroFlare • AllegroFlare Docs • AllegroFlare GitHub

thatrabbit
Member #18,225
August 2020

Wow. Thank-you for all the replies! I should have checked back sooner.

I realized multi-line would not help me in this case. Still it is good to know it exists, and I will refer back here when the time comes.

Cheers all!

-- edit

You must be linking to an old version of allegro

Was correct. I am using 5.0.10. Time to upgrade.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

I have some binaries for Allegro 5.2.5 and MinGW-W64 gcc 8.1.0 on my bitbucket download page. I haven't updated my binary package to 5.2.6 yet, which you can find on the official download page.

Links:

Allegro 5.2.5 and Allegro 4.4.3

https://bitbucket.org/bugsquasher/unofficial-allegro-5-binaries/src/master/

https://bitbucket.org/bugsquasher/unofficial-allegro-5-binaries/downloads/

Official binaries :

https://github.com/liballeg/allegro5/releases

Go to: