|
Code not working when check allegro_init() != 0 |
alex alex
Member #18,271
September 2020
|
Hello everybody, Me introducing myself (you can skip it as it is boring, probably) : I'm new here so I wish to introduce myself a little bit ... My question : I'm coding on Windows 8 and I'm using MingW32, the last version. Yesterday it was a huuuuuge pain is the *** to make Allegro working. I don't even talk about compiling it, I was completely out of luck and I gave up. Now something's really weird happens. Every example codes that I try don't work until I change a single thing : if (allegro_init() != 0) This make the compiled code not working, nothing happen when I launch it. Then if I change the condition from != to == , the code launches perfectly ... I don't get it, is it some kind of compatibility issue ? Thanks for the help PS : I would like to use the ADIME dialogs/gui library, once again I have no luck compiling it I'm really not a nerd. Is there any binary versions of it for windows available ? Or any other similar libraries, already compiled and that looked more or less like windows ? |
Niunio
Member #1,975
March 2002
|
Welcome back. On Allegro 5 it is al_init. Right now it returns boolean value TRUE (non zero) or FALSE (zero). So: if (al_init ()) return 1; If you're using older Allegro, it uses inverse logic. Then for the same result you should use it as: if (!allegro_init ()) return 1;
----------------- |
dthompson
Member #5,749
April 2005
|
Niunio said: Right now it returns boolean value TRUE (non zero) or FALSE (zero). Yes indeed - Allegro 5's al_init returns FALSE if there's a problem. I always found A4's install_* functions to to be unintuitive, because things like create_bitmap were truthy when they succeeded. So, I normally wrote the conditions like this: if(allegro_init() != 0) throw_a_big_error(); if(install_keyboard() != 0) throw_another_error();
______________________________________________________ |
alex alex
Member #18,271
September 2020
|
Thank you a lot for your answers. So it is a compatibility problem between the code and my Allegro version, hopefully there is no other issues and I can focus on my code again. Thanks again, |
RmBeer2
Member #16,660
April 2017
|
hello @alex alex , welcome to Allegro! You can give yourself a good introduction in the offtopic forum or even fill out your profile. About of allegro_init() : https://liballeg.org/stabledocs/en/alleg000.html#install_allegro You can see that it returns 0 if it works correctly, which if it returns any value there was an error. Modify != To == can continue, but this will lead to more errors. You also don't seem to make it clear that you're using Allegro 5 at any point. If you want to continue programming with Allegro 4 you have djgpp. You can found documentations for both libraries here: Allegro 4: https://liballeg.org/stabledocs/en/allegro.html Examples of Allegro 5 here: https://github.com/liballeg/allegro5/tree/master/examples More info here: If you have any problem, do not hesitate to ask. 🌈🌈🌈 🌟 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! |
bamccaig
Member #7,536
July 2006
|
I'm rather confused. OP claims to be using Allegro 4. Allegro 5 is irrelevant. It's rather strange that it "launches perfectly" when ignoring the error status of initializing Allegro though. -- acc.js | al4anim - Allegro 4 Animation library | Allegro 5 VS/NuGet Guide | Allegro.cc Mockup | Allegro.cc <code> Tag | Allegro 4 Timer Example (w/ Semaphores) | Allegro 5 "Winpkg" (MSVC readme) | Bambot | Blog | C++ STL Container Flowchart | Castopulence Software | Check Return Values | Derail? | Is This A Discussion? Flow Chart | Filesystem Hierarchy Standard | Clean Code Talks - Global State and Singletons | How To Use Header Files | GNU/Linux (Debian, Fedora, Gentoo) | rot (rot13, rot47, rotN) | Streaming |
Edgar Reynaldo
Major Reynaldo
May 2007
|
If allegro_init doesn't return 0, it means the library failed to install. This typically happens when the runtime library version doesn't match the compiled version of allegro. It means you have bad dlls somewhere. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
LennyLen
Member #5,313
December 2004
|
RmBeer2 said: If you want to continue programming with Allegro 4 you have djgpp. Why would he use a DOS compiler when he clearly states he's using Windows 8? MinGW and A4 work fine together.
|
alex alex
Member #18,271
September 2020
|
Thank you RmBeer2 for the answer. I'm having a look at the extremely well done tutorials provided in your post. Such a huge step from the last time I used Allegro, it was in the early 90's if I remember well ... I made a gameboy emulator at this time with the help of the library, there was a nice visual debugger, it was pure fun. Of course I used DJGPP at this time. Now, Mingw seems to work perfectly for what I do. I started my new audio software with it, it was supposed to work on the line command only, but as it grows, I need a Gui now. I didn't install Allegro 5. I really tried. Some examples worked, while some others didn't. While they compiled with no error, they had windows give me an error at launch. My tries to compile the fifth installment were a true nightmare. You're supposed to know so much in order to do it successfully, and seriously I just wanted to progress in my coding. As far as I can remember, I installed Allegro 4.4, an already compiled version. At the exception of the allegro init condition, every examples now work perfectly, how would it be possible that the library didn't install properly ? |
RmBeer2
Member #16,660
April 2017
|
@LennyLen : 🌈🌈🌈 🌟 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! |
Arthur Kalliokoski
Second in Command
February 2005
|
RmBeer2 said: Djgpp works on windows too, and is still supported, so it can be used on windows 8 too. True only for 32 bit windows, right? How many people are still using 32 bit OS'es? They all watch too much MSNBC... they get ideas. |
Niunio
Member #1,975
March 2002
|
Arthur Kalliokoski said: How many people are still using 32 bit OS'es? Since 64bits OSes are able to run 32bits programs, who cares. IMO if you don't have very high RAM needs, differences are negligible. I mostly compile for 32bit. ----------------- |
Peter Hull
Member #1,136
March 2001
|
Niunio said: Since 64bits OSes are able to run 32bits programs, who cares. AFAIK 64bit OSes are not able to run 32bit DOS programs.
|
Audric
Member #907
January 2001
|
If you use a Windows port of DJGPP, you're cross-compiling a DOS executable. It means you can only link DOS ports of libraries, and you're building a program that can only talk to the graphic card through VGA or VESA, instead of DirectX / Direct3D / GDI. I can confirm mingw32 (the windows version of mingw-gcc) is a fine way to use your DJGPP experience on a windows machine, because they both have a common close ancestor : gcc |
Arthur Kalliokoski
Second in Command
February 2005
|
Niunio said: Since 64bits OSes are able to run 32bits programs, who cares. IMO if you don't have very high RAM needs, differences are negligible. I mostly compile for 32bit. It's the 16 bit startup stub that Windows trips over, I know from experience. They all watch too much MSNBC... they get ideas. |
Edgar Reynaldo
Major Reynaldo
May 2007
|
DJGPP is for compiling DOS executables. MinGW is for compiling Windows executables. This is not difficult people. And vanilla MinGW is outdated and decrepit. Use MinGW-W64 instead. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Niunio
Member #1,975
March 2002
|
Peter Hull said: AFAIK 64bit OSes are not able to run 32bit DOS programs. I was talking in general, but yes, you're right: DOSbox or something. Why you didn't have luck with that? DOSbox is quite straightforward. ----------------- |
Doctor Cop
Member #16,833
April 2018
|
Hey Alex, what do you do for a living?
|
Rodolfo Lam
Member #16,045
August 2015
|
I second Mayor Reynalda there, minGW-w64 is quite nice and very actively supported. Vainilla MinGW seems to be kinda abandoned nowadays.
|
Peter Hull
Member #1,136
March 2001
|
Niunio said: Why you didn't have luck with that? DOSbox is quite straightforward. I wanted to run 3dspryjinx (when it was new, my PC was too weak to run it!) and I was never able to get it to work without crashing.
|
Arthur Kalliokoski
Second in Command
February 2005
|
DOSbox won't allow instructions that were implemented after the 486. They all watch too much MSNBC... they get ideas. |
RmBeer2
Member #16,660
April 2017
|
3dspryjinx is a very cool game, i've already played it from win98. 🌈🌈🌈 🌟 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! |
|