allegro5 icon indicating copy to clipboard operation
allegro5 copied to clipboard

Doesn't run in vscode on linux mint

Open Shadowblitz16 opened this issue 3 years ago • 7 comments

I followed the information on the wiki repo and I am getting undefined reference errors everywhere

[Running] cd "/home/shadowblitz16/Documents/Projects/Code/SimpleList/" && g++ main.cpp -o main && "/home/shadowblitz16/Documents/Projects/Code/SimpleList/"main
/usr/bin/ld: /tmp/ccla0vfs.o: in function `main':
main.cpp:(.text+0x1d): undefined reference to `al_install_system'
/usr/bin/ld: main.cpp:(.text+0x22): undefined reference to `al_init_font_addon'
/usr/bin/ld: main.cpp:(.text+0x27): undefined reference to `al_init_ttf_addon'
/usr/bin/ld: main.cpp:(.text+0x36): undefined reference to `al_create_display'
/usr/bin/ld: main.cpp:(.text+0x50): undefined reference to `al_load_ttf_font'
/usr/bin/ld: main.cpp:(.text+0x96): undefined reference to `al_map_rgb'
/usr/bin/ld: main.cpp:(.text+0xbd): undefined reference to `al_clear_to_color'
/usr/bin/ld: main.cpp:(.text+0xd1): undefined reference to `al_map_rgb'
/usr/bin/ld: main.cpp:(.text+0x113): undefined reference to `al_draw_text'
/usr/bin/ld: main.cpp:(.text+0x118): undefined reference to `al_flip_display'
collect2: error: ld returned 1 exit status

[Done] exited with code=1 in 0.51 seconds

this is what my code looks like..

#include <iostream>
#include <allegro5/allegro.h>
#include <allegro5/allegro_font.h>
#include <allegro5/allegro_ttf.h>

int main()
{
    al_init();
    al_init_font_addon();
    al_init_ttf_addon();

    ALLEGRO_DISPLAY* display = al_create_display(512,480);
    ALLEGRO_FONT   * font    = al_load_ttf_font("assets/pico8.ttf", 64, 0);

    std::cout << (font == nullptr) << std::endl;

    while (true)
    {
        al_clear_to_color(al_map_rgb(255,255,255));
        al_draw_text(font, al_map_rgb(0,0,0), 0, 0, 0, "Hello World!");

        al_flip_display();
    }

    al_destroy_display(display);
    al_destroy_font(font);
    return 0;
}

Shadowblitz16 avatar Dec 03 '20 02:12 Shadowblitz16

You need to tell g++ to link in the Allegro libraries.

What wiki page were you following? If it tells you to compile like that, it's bad advice.

pedro-w avatar Dec 03 '20 12:12 pedro-w

@pedro-w I was following YouTube tutorials. also I was using vs code's runner plugin.

I moved to windows and got it working.

I still have no idea how to actually run it from vs code.

Shadowblitz16 avatar Dec 04 '20 19:12 Shadowblitz16

@Shadowblitz16 : To consult doubts or problems, you can visit the Allegro forum:

https://www.allegro.cc/forums/board/programming

EDIT: You must also say the links of the tutorials, guides or wiki that you followed.

rmbeer avatar Dec 12 '20 11:12 rmbeer

I've made some notes on this but I haven't typed them up yet

pedro-w avatar Dec 12 '20 11:12 pedro-w

@Shadowblitz16 I've done this https://github.com/liballeg/allegro_wiki/wiki/Using-Visual-Studio-Code Still a WIP so I haven't linked it to the main content of the wiki. What do you think?

pedro-w avatar Dec 17 '20 09:12 pedro-w

I don't know everytime I try c or c++ I run into a enormous amount of issues..

  • ide's and text editors not working
  • the requirement of make files
  • compiler errors that don't maker sense.

I think me staying away from c and c++ is probably a good thing. however I hope that this issue I raised will help someone else

Shadowblitz16 avatar Dec 21 '20 05:12 Shadowblitz16

It's like riding a bike. Here is not the place for discussion, though, why not go to allegro.cc and people will help you.

pedro-w avatar Dec 21 '20 07:12 pedro-w