My code has absolutely no errors in it, and runs fine if I Run it from my Dev environment after compiling. However, when I try to run it without mingwstudio, it says there was an error in alleg42.dll...
I just installed allegro 4.2 if that has anything to do with it...
If you need to see my code, it's (xero.h is just a bunch of global variables used for multiple source files):
| 1 | #include <allegro.h> |
| 2 | #include "xero.h" |
| 3 | |
| 4 | BITMAP *buffer; |
| 5 | MIDI *bgmusic; |
| 6 | |
| 7 | |
| 8 | int Allegro_Init(){ |
| 9 | int rtv; |
| 10 | if (allegro_init() != 0) {return 1;} |
| 11 | install_keyboard(); |
| 12 | install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL); |
| 13 | if (install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL) != 0) { |
| 14 | allegro_message("Error initialising sound system\n%s\n", allegro_error); |
| 15 | return 1; |
| 16 | } |
| 17 | set_color_depth(16); |
| 18 | rtv=set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640,480,0,0); |
| 19 | if (rtv!=0) |
| 20 | { |
| 21 | set_gfx_mode(GFX_TEXT,0,0,0,0); |
| 22 | allegro_message("Error setting graphics mode\n%s\n", allegro_error); |
| 23 | return 1; |
| 24 | } |
| 25 | buffer=create_bitmap(640,480); |
| 26 | } |
| 27 | |
| 28 | int main(int argc, char *argv[]){ |
| 29 | Allegro_Init(); |
| 30 | int mcy = 150; |
| 31 | int enter = 0; |
| 32 | BITMAP *curs = NULL; |
| 33 | BITMAP *menu = NULL; |
| 34 | BITMAP *bg = NULL; |
| 35 | bgmusic = load_midi("bgmusic.mid"); |
| 36 | play_midi(bgmusic, TRUE); |
| 37 | bg = load_bitmap("bg.bmp", NULL); |
| 38 | curs = load_bitmap("curs.bmp", NULL); |
| 39 | menu = load_bitmap("menu.bmp", NULL); |
| 40 | do { |
| 41 | if (!bgmusic) { |
| 42 | allegro_message("Error reading MIDI file '%s'\n", argv[1]); |
| 43 | return 1; |
| 44 | } |
| 45 | blit(bg,buffer,0,0,0,0,640,480); |
| 46 | blit(menu,buffer,0,0,190,100,240,192); |
| 47 | blit(curs,buffer,0,0,240,mcy,30,11); |
| 48 | textout(buffer, font, "Xero Gunman -- Lone Hero", 220, 5, makecol(255,255,255)); |
| 49 | textout(buffer, font, "Start Game", 280, 152, makecol(255,255,255)); |
| 50 | textout(buffer, font, "Quit Game", 280, 177, makecol(255,255,255)); |
| 51 | blit(buffer, screen,0,0,0,0,640,480); |
| 52 | if(key[KEY_ESC]){ |
| 53 | exit(enter); |
| 54 | } |
| 55 | if(key[KEY_ENTER]){ |
| 56 | enter += 1; |
| 57 | } |
| 58 | if(key[KEY_DOWN] && mcy == 150){ |
| 59 | mcy += 25; |
| 60 | clear_bitmap(buffer); |
| 61 | } |
| 62 | if(key[KEY_UP] && mcy == 175){ |
| 63 | mcy -= 25; |
| 64 | clear_bitmap(buffer); |
| 65 | } |
| 66 | if(mcy == 175 && key[KEY_ENTER]){ |
| 67 | exit(enter); |
| 68 | } |
| 69 | if(mcy == 150 && key[KEY_ENTER]){ |
| 70 | enter = 1; |
| 71 | } |
| 72 | } |
| 73 | while(enter == 0); |
| 74 | stop_midi(); |
| 75 | return 0; |
| 76 | } |
| 77 | END_OF_MAIN() |
bgmusic = load_midi("bgmusic.mid");
Check the return codes. If bgmusic == NULL, then your files aren't being loaded.
... the music loads fine...
the problem is the whole code works for me under mingwstudio, its just that when I run it from outside the program, it doesnt work. But when I click "Build and run" from mingwstudio, it runs perfectly with no error.
otherwise it says there was an error in alleg42.dll... I think It has to do with me reinstalling allegro to get the new version...
Im going to attach my program in a .zip...
please tell me if it runs without an error...
remember, it works fine from my dev environment AND my debugger, just not when I click on the stand alone executable...
(the music is NOT copyright to me)
Perhaps mingwstudio (whatever that is) runs the program from some obscure directory in which the correct version of alleg42.dll is?
I should have been more clear in describing what "MinGW Studio" is...
its an IDE for mingw, much like Dev-CPP with more features, and the full mingw compiler (unlike what dev-cpp used to be... havent used that for years now though...)
the reason I think it doesnt run outside the interpreter has something to do with my updating allegro is because it worked fine with the old version, but I wanted to stay on edge, so I updated...
The program itself seems to run fine (albeit its nowhere near finished).
the real problem lies in that my computer isnt reading alleg40.dll correctly...
maybe I'll try deleting my environment and reinstalling, that might work...
thanks for trying to help anyway, and sorry I was so brief in explaining my situation...
Search for the dll. I guess it is inside MinGW Studio directory somewhere. Copy it to System32 and it should work.