Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » My game doesn't starts on any computer :(

This thread is locked; no one can reply to it. rss feed Print
 1   2 
My game doesn't starts on any computer :(
LennyLen
Member #5,313
December 2004
avatar

Quote:

I'm probably going to uninstall DevC++ and allegro then, because all of these weird problems I've had. I think that something maybe went wrong in the installation process of allegro. I have also heard that DevC++ compiler etc. is kind of otherwise and sometimes weird.

While I personally dislike the Dev-C++ IDE, it's not the source of your problem. There are many people on this forum who use it regularly without experiencing any of the problems you describe. Based on this, and what you've said so far in this thread, it's more likely that the problem is simply that you have no idea what you are doing.

James Stanley
Member #7,275
May 2006
avatar

Do you have the allegro runtimes on the computers it doesn't work on? Try putting alleg42.dll in your executables directory. I don't know...

LennyLen
Member #5,313
December 2004
avatar

@ _mEck0: Can you zip up and attach your code?

_mEck0
Member #7,650
August 2006

Yes, I can... I showed the game for my teacher, it was ok, but I must fix the problem so it executes on any computer... Maybe something is wrong with the paths.

Thank you very much, I really appreciate your help, because this problem is very important for me.

Indeterminatus
Member #737
November 2000
avatar

_mEck0, please see this.

_______________________________
Indeterminatus. [Atomic Butcher]
si tacuisses, philosophus mansisses

_mEck0
Member #7,650
August 2006

Quote:

_mEck0, please see this [dashumankapital.net].

Okey, I understand that now.

Tobias Dammers
Member #2,604
August 2002
avatar

I'll say it again: Real men don't need IDE's.

Really, to learn programming, I can only advise to use nothing but a good editor and the command line. This way, you learn how to do things on your own; you'll understand what a compiler is, what a linker is, and what all those different file types (.cpp, .h, .o, .a, .dll, .exe, makefile) are for. You'll also learn to use proper coding style.

Once you've gone through that hell and know what you're doing, then go and use an IDE to make your life easier (unless you like the amount of direct control the 'spartan's IDE' gives you).

My personal choice is command line + SciTE. SciTE is basically an editor with syntax highlighting, a light app that starts quickly and doesn't use resources to do unnecessary fancy stuff, but it still has some rudimentary IDE functions like F7 to invoke make, and it understands g++ output so you can jump to the error directly.

---
Me make music: Triofobie
---
"We need Tobias and his awesome trombone, too." - Johan Halmén

_mEck0
Member #7,650
August 2006

Thanks for the tips!

piccolo
Member #3,163
January 2003
avatar

great choose msvs 2005 is nice but see if you can get your hands on msvs6 ,it has much more goodies to help you do flasher things with ease. and its is very stable;D

wow
-------------------------------
i am who you are not am i

Richard Phipps
Member #1,632
November 2001
avatar

LennyLen
Member #5,313
December 2004
avatar

Um... I thought you said you didn't use absolute paths:

     BITMAP* load_6 = load_tga("C:/bilspel/RallyCross/Graphics/Splashscreen/load_6.tga",palette);
     BITMAP* load_5 = load_tga("C:/bilspel/RallyCross/Graphics/Splashscreen/load_5.tga",palette);
     BITMAP* load_4 = load_tga("C:/bilspel/RallyCross/Graphics/Splashscreen/load_4.tga",palette);
     BITMAP* load_3 = load_tga("C:/bilspel/RallyCross/Graphics/Splashscreen/load_3.tga",palette);
     BITMAP* load_2 = load_tga("C:/bilspel/RallyCross/Graphics/Splashscreen/load_2.tga",palette);

Your code also throws up several compiler warnings, some of which you shouldn't have ignored (I'm giving you the benefit of the doubt, and am hoping that the ones refering to unused BITMAPS are for as yet unimplimented features). And while I can get the code to eventually compile without warnings, it crashes immediately when I run it. You haven't implemented any error checking, and I'm not in the mood to add any to see if I can find out why it's crashing.

Your program also needlessly includes "winalleg.h", and I think you need to ask your teacher what the purpose of header files is, as you have function declarations and defnitions scattered willy nilly through your source and header file.

I second Tobias, learn how to program using just a text editor and the command line. Once you understand how things work, then start using more complicated tools like an IDE.

Michael Faerber
Member #4,800
July 2004
avatar

Quote:

I second Tobias, learn how to program using just a text editor and the command line. Once you understand how things work, then start using more complicated tools like an IDE.

However, I think that using the command line in Windows SUCKS. If commandline, then Linux. ;)

--
"The basic of informatics is Microsoft Office." - An informatics teacher in our school
"Do you know Linux?" "Linux? Isn't that something for visually impaired people?"

Tobias Dammers
Member #2,604
August 2002
avatar

Lenny, look out for the tiny blue monsters!

Right, to the point:
load_bitmap() isn't the only allegro function that can fail, actually, most can. Especially the initialization routines (setting gfx mode etc.) are definitely worth error-checking.
Then; learn to debug. Debugging is not pushing the F8 key. Debugging means inspecting the program while running to see what exactly is the problem. For this, it is common to use a debugger (MSVC comes with one), which is a tool that enables you to execute your code step-by step (much like an interpreter), define 'breakpoints' (lines at which the program will pause), inspect the values of variables at run-time, and get a 'call stack' (list of function calls that got you where you are in the code). Very useful, but unfortunately, many debuggers suffer bugs, or are hard to understand; with the exception of JIT (just-in-time) debuggers like DrMingw - these programs only kick in after the program crashes; they will then show you where and how the program crashed (though it's up to you to figure out why).
If you don't want to use a debugger, the least you can do is put lots of printf() or TRACE() statements into your code to find out where exactly the program crashes. I like to use printf("%s, %i\n", _FILE_, _LINE_); which outputs something like "main.cpp, 21", meaning that everything worked well until at least line 21 in main.cpp.
Use this technique to boil the problem down to, ideally, a few lines of code. Write a 10-line program that has the same problem, and someone will fix it.

Go on, flame me.

[edit]
The command line in windows xp is much better than the win98 one, though far from linux. There is a windows version of bash somewhere though IIRC.

---
Me make music: Triofobie
---
"We need Tobias and his awesome trombone, too." - Johan Halmén

Richard Phipps
Member #1,632
November 2001
avatar

BITMAP* load_6 = load_tga("C:/bilspel/RallyCross/Graphics/Splashscreen/load_6.tga",palette);
>:(

_mEck0
Member #7,650
August 2006

Quote:

Um... I thought you said you didn't use absolute paths:

BITMAP* load_6 = load_tga("C:/bilspel/RallyCross/Graphics/Splashscreen/load_6.tga",palette);
BITMAP* load_5 = load_tga("C:/bilspel/RallyCross/Graphics/Splashscreen/load_5.tga",palette);
BITMAP* load_4 = load_tga("C:/bilspel/RallyCross/Graphics/Splashscreen/load_4.tga",palette);
BITMAP* load_3 = load_tga("C:/bilspel/RallyCross/Graphics/Splashscreen/load_3.tga",palette);
BITMAP* load_2 = load_tga("C:/bilspel/RallyCross/Graphics/Splashscreen/load_2.tga",palette);

These sentences I just wrote when I tested som stuff, because I don't have absolute paths on any other place in the code.

Quote:

Your program also needlessly includes "winalleg.h", and I think you need to ask your teacher what the purpose of header files is, as you have function declarations and defnitions scattered willy nilly through your source and header file.

I'll accidently forgot to remove the include of winalleg.h. From start I wanted to make an win32 gui, but this programming course was pretty small so I didn't have much time to program.

I just got one warning when I compile, but I'll take a look and try to fix it. Yes I know what a headerfile is, I have programmed before, but not anything "big" as this project, just small stuff we needed to do in school, and I haven't barely used allegro, so can you please explain what you mean by function declarations and definitions scattered willy nilly through the source code? I have programmed before, but I still see myself like a newbie (even I can a lot more then a "real" newbie who just started to code), so can you give an example what is wrong with my declarations and definitions? Actually this is the way I've learned to write from school. Because I want to correct and learn from my errors and by the way, everyone is a newbie from start and doesn't program like a more experienced programmer. It takes time to learn ;)

I'll remove the link to my project files now, but thanks for helping me.

BAF
Member #2,981
December 2002
avatar

Once, again, ignore piccolo about MSVC 6. If you're actually interested in it, you can find more info, including on setting up Allegro, here

MSVC Express is free.

_mEck0
Member #7,650
August 2006

Okey, I understand.

LennyLen
Member #5,313
December 2004
avatar

Quote:

Actually this is the way I've learned to write from school.

Then you either need new teachers, or to pay more attention. ;)

A header file should NOT include any funtion definitions, just declarations. If you're going to put them both into the same file, then you may as well just rename it .c/.cpp as it's a source file, not a header file.

Try reading this: http://en.wikipedia.org/wiki/Header_file

_mEck0
Member #7,650
August 2006

Quote:

Quote:
Actually this is the way I've learned to write from school.
Then you either need new teachers, or to pay more attention. ;)

A header file should NOT include any funtion definitions, just declarations. If you're going to put them both into the same file, then you may as well just rename it .c/.cpp as it's a source file, not a header file.

Try reading this: http://en.wikipedia.org/wiki/Header_file

I can't remember that my teacher said that you shouldn't do so ??? and when she looked at my source code, she didn't asked why I did so, probably she doesn't know it either (she doesn't have so much programming experience as far as I know). But I'm glad I've found this site so you guys can correct my mistakes ;D Thanks for the link, I'll read that now and correct the fault in my code.

Arthur Kalliokoski
Second in Command
February 2005
avatar

The reason you don't want functions declared in a header file is because the header file gets included into many .c/.cpp files. (or otherwise just put the #defines etc. in the one file unless it's for a library). BUT if you have a function in that header file, all the .c/.cpp files will all tell the linker that THEY have the one true function. So the linker complains that it can't tell which one to use or just picks one at random.

Similarly you don't want to have variable names that are the same as function names (in C anyway) since compilers/linkers aren't smart enough all the time.

They all watch too much MSNBC... they get ideas.

_mEck0
Member #7,650
August 2006

Oh, I'm so happy now that it's indescribable :D8-);D:) I have fixed the bug which did that I couldn't execute my game on any computer! I copied the game-dir to a computer which I don't have allegro and DevC++ installed on, and it worked correctly, Windows doesn't search for dll-files anymore...

I fixed some warnings (there is one left to fix), then I corrected som paths and I moved the functiondefinition (for the "settings"-function) from my headerfile to the main cpp-file, and that's it ;D

Thank you guys, without your tips and comments I don't think I've had fixed it so fast...

Dragonsoulj
Member #7,678
August 2006

Granted it looks like this problem is solved, I would like to mention _mEck0 that Dev-C++ does have a debugger that does just as Tobias Dammers said:
Debugging means inspecting the program while running to see what exactly is the problem. For this, it is common to use a debugger (MSVC comes with one), which is a tool that enables you to execute your code step-by step (much like an interpreter), define 'breakpoints' (lines at which the program will pause), inspect the values of variables at run-time, and get a 'call stack' (list of function calls that got you where you are in the code). Very useful, but unfortunately, many debuggers suffer bugs, or are hard to understand; with the exception of JIT (just-in-time) debuggers like DrMingw - these programs only kick in after the program crashes; they will then show you where and how the program crashed (though it's up to you to figure out why).
</quote>There is an option in Dev-C++ to "execute your code step-by-step" that let's you debug your programs. If you look at the bottom of Dev-Cpp you can find the debug tab. Click it and click debug and it will run the debugger that lets you run your code step by step.
And about your allegro library not being installed right. Install Dev-Cpp on your computer, then either download Allegro off the site, off of the devpaks.org, or find it under Tools -> Check for Updates/Packages... in Dev-Cpp. Once you have the .zip folder or the devpak folder, go into the package manager (Tools -> Package Manager) click install, then find the folder. Go through the wizard and it will be properly installed. You can do the same for the DirectX Stuff and they both will be installed. I haven't had anymore problems with Dev-Cpp when I did it this way. I still for some reason have to add the liballeg.a file, though.

Tobias Dammers
Member #2,604
August 2002
avatar

Quote:

So the linker complains that it can't tell which one to use or just picks one at random.

The linker won't pick one at random - that would be just fine in most cases (except that it generates unnecessarily long compile times). It will complain that several distinct functions with identical signature exist.

---
Me make music: Triofobie
---
"We need Tobias and his awesome trombone, too." - Johan Halmén

Matt Smith
Member #783
November 2000

Quote:

It will complain that several distinct functions with identical signature exist.

gcc link will not. It will always use the first one in the list of libs you give it. This is useful sometimes as it allows you to override functions in Allegro (e.g. you copy the Allegro function into your source file and add extra debugging code)

CursedTyrant
Member #7,080
April 2006
avatar

Quote:

So, I think I'll install Visual Studio 2005 Express instead and allegro to it, is it a good choice?

Uhhh... no? Visual Studio is weird. I've been using Dev-Cpp for a few years before I switched to plain old Programmer's Notepad 2 and MinGW32 and never had any serious problems with it.

---------
Signature.
----
[My Website] | [My YouTube Channel]

 1   2 


Go to: