Panel użytkownika
Nazwa użytkownika:
Hasło:
Nie masz jeszcze konta?

Podlinkowywanie Allegro5.

Ostatnio zmodyfikowano 2013-02-24 21:27
Autor Wiadomość
Trotom
Temat założony przez niniejszego użytkownika
Podlinkowywanie Allegro5.
» 2013-02-24 11:35:18
Witam,

Kolejna próba, kolejny problem. Chce pracować w Code::Blocks, wykorzystując Allegro5 na Ubuntu. Wydaje się to chyba niewykonywalne. Googlowałem dużo. Od razu mówię, iż z moim angielskim jest średnio. A oto błędy jakie wywalał:


-------------- Build: Debug in Test (compiler: GNU GCC Compiler)---------------

g++ -L/home/tom/C++/biblioteki/Aktualne -L/home/tom/C++/biblioteki -L/usr/local/lib  -o bin/Debug/Test obj/Debug/Test.o   'allegro-config --libs --static' 
obj/Debug/Test.o: In function `main':
/home/tom/C++/projekty/Allegro 5/Test/Test.cpp:7: undefined reference to `al_install_system'
/home/tom/C++/projekty/Allegro 5/Test/Test.cpp:10: undefined reference to `al_show_native_message_box'
/home/tom/C++/projekty/Allegro 5/Test/Test.cpp:13: undefined reference to `al_set_new_window_position'
/home/tom/C++/projekty/Allegro 5/Test/Test.cpp:14: undefined reference to `al_set_new_display_flags'
/home/tom/C++/projekty/Allegro 5/Test/Test.cpp:15: undefined reference to `al_create_display'
/home/tom/C++/projekty/Allegro 5/Test/Test.cpp:19: undefined reference to `al_show_native_message_box'
/home/tom/C++/projekty/Allegro 5/Test/Test.cpp:22: undefined reference to `al_set_window_title'
/home/tom/C++/projekty/Allegro 5/Test/Test.cpp:24: undefined reference to `al_create_bitmap'
/home/tom/C++/projekty/Allegro 5/Test/Test.cpp:25: undefined reference to `al_create_bitmap'
/home/tom/C++/projekty/Allegro 5/Test/Test.cpp:29: undefined reference to `al_show_native_message_box'
/home/tom/C++/projekty/Allegro 5/Test/Test.cpp:32: undefined reference to `al_set_target_bitmap'
/home/tom/C++/projekty/Allegro 5/Test/Test.cpp:33: undefined reference to `al_map_rgb'
/home/tom/C++/projekty/Allegro 5/Test/Test.cpp:33: undefined reference to `al_clear_to_color'
/home/tom/C++/projekty/Allegro 5/Test/Test.cpp:34: undefined reference to `al_set_target_bitmap'
/home/tom/C++/projekty/Allegro 5/Test/Test.cpp:35: undefined reference to `al_map_rgb'
/home/tom/C++/projekty/Allegro 5/Test/Test.cpp:35: undefined reference to `al_clear_to_color'
/home/tom/C++/projekty/Allegro 5/Test/Test.cpp:36: undefined reference to `al_get_backbuffer'
/home/tom/C++/projekty/Allegro 5/Test/Test.cpp:36: undefined reference to `al_set_target_bitmap'
/home/tom/C++/projekty/Allegro 5/Test/Test.cpp:37: undefined reference to `al_map_rgb_f'
/home/tom/C++/projekty/Allegro 5/Test/Test.cpp:37: undefined reference to `al_clear_to_color'
/home/tom/C++/projekty/Allegro 5/Test/Test.cpp:38: undefined reference to `al_draw_bitmap'
/home/tom/C++/projekty/Allegro 5/Test/Test.cpp:39: undefined reference to `al_draw_bitmap'
/home/tom/C++/projekty/Allegro 5/Test/Test.cpp:40: undefined reference to `al_flip_display'
/home/tom/C++/projekty/Allegro 5/Test/Test.cpp:41: undefined reference to `al_rest'
/home/tom/C++/projekty/Allegro 5/Test/Test.cpp:42: undefined reference to `al_destroy_display'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
25 errors, 0 warnings (0 minutes, 0 seconds)

Na ten program:

C/C++
// Program kolory i inicjowanie Allegro
#include <allegro.h>
#include <allegro_native_dialog.h>
ALLEGRO_DISPLAY * okno = NULL;
int main()
{
    if( !al_init() ) {
        al_show_native_message_box( okno, "Błąd", "hej no co?",
        "Nie mogę zainicjować Allegro5!\n weź się ogarnij!",
        NULL, ALLEGRO_MESSAGEBOX_ERROR );
        return 0;
    }
    al_set_new_window_position( 20, 30 );
    al_set_new_display_flags( ALLEGRO_WINDOWED );
    okno = al_create_display( 320, 240 );
    if( !okno ) {
        al_show_native_message_box( okno, "Błąd", "NULL",
        "Nie mogę utworzyć okna!",
        NULL, ALLEGRO_MESSAGEBOX_ERROR );
        return 0;
    }
    al_set_window_title( okno, "Kolory i inicjowanie Allegro5" );
    ALLEGRO_BITMAP * kwadrat, * prostokat = NULL;
    kwadrat = al_create_bitmap( 50, 50 );
    prostokat = al_create_bitmap( 100, 50 );
    if( !kwadrat or !prostokat ) {
        al_show_native_message_box( okno, "Błąd", "Coś nie tak",
        "Nie mogę utworzyć bitmap!",
        NULL, ALLEGRO_MESSAGEBOX_ERROR );
        return 0;
    }
    al_set_target_bitmap( kwadrat );
    al_clear_to_color( al_map_rgb( 0, 255, 0 ) );
    al_set_target_bitmap( prostokat );
    al_clear_to_color( al_map_rgb( 255, 0, 0 ) );
    al_set_target_bitmap( al_get_backbuffer( okno ) );
    al_clear_to_color( al_map_rgb_f( 1.0, 1.0, 0.0 ) );
    al_draw_bitmap( kwadrat, 100, 100, 0 );
    al_draw_bitmap( prostokat, 125, 125, 0 );
    al_flip_display();
    al_rest( 5.0 );
    al_destroy_display( okno ); //usuwamy okno z pamięci i zwalniamy pamięć
    return 0;
}
EDIT:
Jeszcze trochę pogooglowałem i znalazłem stronę (https://www.allegro.cc/forums/thread/609001), w ktrej nie rozumiem dwóch fraz, a mianowicie:
Linker Settings tab -> [Link Libraries | Other linker options] -> Add the path to the libraries to link to, or add the linker flags to link to them.

Link to a library named lib*.a by using -l*, where you replace * with whatever is there in the library name.

Możecie mi wytłumaczyć o co tu chodzi?
P-76875
pekfos
» 2013-02-24 12:35:16
'allegro-config --libs --static'
A to co?
P-76877
Trotom
Temat założony przez niniejszego użytkownika
» 2013-02-24 12:48:45
To z Settings -> Compiler -> Linker settings -> Other linker options.
P-76878
Trotom
Temat założony przez niniejszego użytkownika
Odświeżam
» 2013-02-24 17:01:29
Przepraszam, za podówjny post, ale chcę odświeżyć ten temat.
Jeszcze trochę pogooglowałem i znalazłem stronę (https://www.allegro.cc/forums/thread/609001), w ktrej nie rozumiem dwóch fraz, a mianowicie:
"
Linker Settings tab -> [Link Libraries | Other linker options] -> Add the path to the libraries to link to, or add the linker flags to link to them.

Link to a library named lib*.a by using -l*, where you replace * with whatever is there in the library name.
"
Możecie mi wytłumaczyć o co tu chodzi?
P-76898
pekfos
» 2013-02-24 20:43:23
Skoro aż tak źle z twoim angielskim, to szukaj polskich materiałów. Dużo mniejszy wybór, ale prędzej coś zrozumiesz.

http://cpp0x.pl/forum/temat/?id=976
Drugi post.
P-76912
Trotom
Temat założony przez niniejszego użytkownika
» 2013-02-24 21:18:35
Dzięki, ale mam jeszcze jedno pytanie: Trzeba to robić dla każdego projektu oddzielnie wypisując wszystkie biblioteki?
P-76917
mactec
» 2013-02-24 21:22:10
@Trotom
tak
P-76918
Trotom
Temat założony przez niniejszego użytkownika
» 2013-02-24 21:27:51
A jak podlinkować biblioteki z zakończeniem cyfrowym, np.: liballegro_dialog.so.5.0.9?
Trochę inaczej. Gdy podlinkwałem dwie potrzebne do tego programu biblioteki, konsola się odpaliła i pokazała mi taki komunikat:

/home/Trotom/C++/projekty/Allegro 5/Test/bin/Debug/Test: error while loading share libraries: liballegro.so.5.0: cannot open shared object file: No such file or directory
I moje zapytanie brzmi: Mam podlinkować tą bibliotekę, jeżeli tak to jak, skoro ma numer na końcu, a jeżeli nie to co mam zrobić.
Edit:
@up A jednak nie. Settings -> Compiler -> Linker settings -> Other linker settings
P-76920
« 1 »
  Strona 1 z 1