Indefinite reference error - Allegro 5

Asked

Viewed 227 times

0

I installed the lib Allegro 5 with the following script :

cd ~/Documentos

sudo apt install -y git build-essential subversion cmake xorg-dev libgl1-mesa-dev libglu-dev install libpng-dev libz-dev libcurl4-gnutls-dev libfreetype6-dev libjpeg-dev libvorbis-dev libopenal-dev libphysfs-dev libgtk2.0-dev libasound-dev libflac-dev libdumb1-dev install exuberant-ctags dvi2ps dvipdfmx latex2html pandoc

git clone https://github.com/liballeg/allegro5.git allegro

sudo mv ~/Documentos/allegro /opt

cd /opt/allegro && cmake -DCMAKE_INSTALL_PREFIX=/usr .

make

sudo make install

So I created a file .c, I imported the lib and compiled the code with the following commands : gcc -Wall -Wextra teste.c -o Test and gcc -lallegro -Wall -Wextra teste.c -o Test, received the following output :

/tmp/ccnmnCzr.o: na função `main':
teste.c:(.text+0x1c): referência indefinida para `al_create_display'
teste.c:(.text+0x34): referência indefinida para `al_map_rgb'
teste.c:(.text+0x61): referência indefinida para `al_clear_to_color'
teste.c:(.text+0x66): referência indefinida para `al_flip_display'
teste.c:(.text+0x7b): referência indefinida para `al_rest'
teste.c:(.text+0x87): referência indefinida para `al_destroy_display'
collect2: error: ld returned 1 exit status

Does anyone know how to fix it, I looked it up, and I found answers like : Returned 1 Exit status - C code indicating syntax error correction, What does " collect2: error: Ld returned 1 Exit status " Mean ? indicating a possible error in the compilation process among other questions that have not made clear how to resolve, in this context of Allegro 5.

Codes I used to test :

# include <stdio.h>

# include <allegro5/allegro.h>

int main(){ // Este exemplo roda sem erros !

    return 0;

}

And this example of Allegro itself ( This is the example that generates the error mentioned above ).

Obs : All programs, libs ... are up to date, I restarted the computer and tested other examples, but it’s still the same.

  • Ubuntu has /usr/lib32 or /usr/lib64?

  • 1

    This error happens if the GCC does not find Allegro’s Ibraries. This usually occurs on Linux’s which by default installs the Libraries in /usr/lib64. You have to modify the LIBDIR of the build process to /usr/lib64, because you can usually install it in the directory with the 32-bit libs. Check if that’s your case, please.

  • Neither of the two options you indicated, i.imgur.com/hpjWma1.png, just lib ... the process would be the same, I mean modifying Lib Dir ?

  • so your machine is 32 bits? Or better your Linux is 32bits?

  • The machine is 64 / 86 ( I.imgur.com/hFgxO6N.png ) and the distribution is Ubuntu Budgie 64 Bits ( 17.10 )

  • 1

    I know we’re supposed to be in the chat room, but run find /usr -iname 'liballegro*', and you can see where you installed it. I can’t see the images because I’m behind a firewall.

  • 1

    I’ll use the chat. I’ll call you there. And then I’ll post an answer.

  • Quiet, the images are just a confirmation for what I’m talking about in text ^ - ^. Most are in /usr/lib/liballegro_*.so , /usr/lib/x86_64-linux-gnu/* and /usr/share/doc/liballegro*.so

Show 4 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.