Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Setup Allegro5 on Visual Studio Code on Mac

Credits go to Edgar Reynaldo and SiegeLord for helping out!
This thread is locked; no one can reply to it. rss feed Print
Setup Allegro5 on Visual Studio Code on Mac
Onewing
Member #6,152
August 2005
avatar

I was going to try out Visual Studio Code on Mac. I haven't really used it before...nor have I really used Allegro 5. It'd be fun to try these things out for the upcoming TINS competition in October. Of course, I wouldn't want to spend time during the competition learning how to use these things. 8-)

Has anyone done this before? I did a search on the site and the googles, but didn't find anything, albeit only after about 5 minutes of searching.

Thoughts on a starting place?

------------
Solo-Games.org | My Tech Blog: The Digital Helm

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

SiegeLord
Member #7,827
October 2006
avatar

Probably not Nuget, as that's Windows-only at the moment. I guess you just install Allegro via homebrew and then do the usual linker options thing?

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Onewing
Member #6,152
August 2005
avatar

I'm a bit stuck. VS Code takes some grunt work to get it going, but I finally got it to compile allegro 5 code, yay! Unfortunately, when I run it, al_init is returning a 1. Searching the forums, this seems to be a symptom of having different versions of allegro between compilation and headers (or something like that).

I went to /usr/local/lib and moved files with "5.2.2" and "5.2" off to other folders (in case I need to move them back). Still no luck. Thoughts?

Not sure if it will help, but here's my code and how I'm compiling it.

#SelectExpand
1#define ALLEGRO_NO_MAGIC_MAIN 2#include <allegro5/allegro.h> 3#include <iostream> 4using namespace std; 5 6int real_main(int argc, char **argv) { 7 if(al_init() != 0) { 8 return 1; 9 } 10 11 cout << "Hello world!" << endl; 12 13 return 0; 14} 15 16int main(int argc, char **argv) { 17 return al_run_main(argc, argv, real_main); 18}

Compile flags

#SelectExpand
1g++ -g helloworld.cpp -Wall -ansi -o test20.exe -L/usr/local/lib/ -I/usr/local/include/ -lallegro

------------
Solo-Games.org | My Tech Blog: The Digital Helm

SiegeLord
Member #7,827
October 2006
avatar

lolz, you know when you're an old A4 programmer when you expect it to return 0 on success ;).

al_init returns a boolean, true when everything worked, false when there was an error.

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Onewing
Member #6,152
August 2005
avatar

Heh, it didn't even occur to me that the problem was in the code considering how much time I spent making VS Code do my bidding. Made the code change and it worked!

FYI, is it just me or is every tutorial on this page running into an Internal Error? https://wiki.allegro.cc/index.php?title=Allegro_5_API_Tutorials

------------
Solo-Games.org | My Tech Blog: The Digital Helm

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Go to: