Allegro errors during tutorial?

Recommended Posts

polisasimo    158
hello I have just gone through the allegro installation tutorial. During the first tutorial I have come across and don't understand the following errors when compiling. here is the code
/*******************
Allegro Newbie Tutorial

#include <allegro.h> // You must include the Allegro Header file

int main(int argc, char argv[])
{

allegro_init(); // Initialize Allegro
install_keyboard(); // Initialize keyboard routines

/***************************
set_gfx_mode will set the graphics mode that you will

Here is what each paramater is

set_gfx_mode(GRAPHICS MODE, Width, Height, Virtual Width, Virtual Height);

GFX_AUTODETECT for a graphics mode will set everything for you, using
the machine's preinstalled drivers.

The width and the height are simple that, the width and the height of
the screen.

The V_Width and V_Height are the virtual (not visible) width and height
of the screen. We don't need to worry about these for the moment, so entering
0's will just create NO virtual screen.
****************************/
set_gfx_mode(GFX_AUTODETECT, 640,480,0,0); // Change our graphics mode to 640x480

/********************************************
This function stops the program untill a key
is pressed
********************************************/
readkey();// Wait untill a key is pressed

return(0);// Exit with no errors
}
END_OF_MAIN(); // This must be called right after the closing bracket of your MAIN function.
// It is Allegro specific.


here are the errors: chris fatal error LNK1120: 6 unresolved externals chris error LNK2019: unresolved external symbol __imp___WinMain referenced in function _WinMain@16 chris error LNK2019: unresolved external symbol __imp__install_allegro referenced in function "int __cdecl _mangled_main(int,char * const)" (?_mangled_main@@YAHHQAD@Z) chris error LNK2019: unresolved external symbol __imp__install_keyboard referenced in function "int __cdecl _mangled_main(int,char * const)" (?_mangled_main@@YAHHQAD@Z) chris error LNK2019: unresolved external symbol __imp__set_gfx_mode referenced in function "int __cdecl _mangled_main(int,char * const)" (?_mangled_main@@YAHHQAD@Z) chris error LNK2019: unresolved external symbol __imp__readkey referenced in function "int __cdecl _mangled_main(int,char * const)" (?_mangled_main@@YAHHQAD@Z) c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\allegro\inline\draw.inl(365): warning C4312: 'type cast' : conversion from 'unsigned long' to 'unsigned long *' of greater size any help on this matter would be appreciated. [Edited by - polisasimo on March 28, 2005 5:25:20 PM]

Share on other sites
-lalleg_s -lgdi32 -ldxguid -lole32 -ldinput -lddraw -lwinmm -ldsound
and this in the C++ compiler from projects->project options

Share on other sites
Drew_Benton    1861
 Whoa, hothead killed me! Either I type too slow or you type too fast [grin]

You will need to link in -lalleg This can be done in the: Project->Project Options->Parameters->Linker Box. It will compile after that assuming you made the correct C++ format console project [smile]

Share on other sites
polisasimo    158
I am using the .net2003 compiler. Under project there is no .... what is the correct term?.... Option for "project options." However under properties I can open up a box for linker. under linker I have the following categories:

general
input
debugging
system
embedded IDL
optimization
command line

am I on the right track

ps thanks so far

Share on other sites
Drew_Benton    1861
Holy cow! I wonder why I assumed you were using Dev-CPP as well [lol] That's just crazy, your error says "Microsoft Visual Studio .NET". Anyways, Project->Properties->Linker->Input then add in alleg.lib to the Additional Dependecies edit box. Then that *should* compile fine.

Well I know why, most people that use Allegro 99% of the time use Dev-CPP [smile] I think you are the first encounter with a .Net compiler in a while.

Share on other sites
polisasimo    158
Allright that killed some of the errors, by the way in the learning curve (which is where I am sitting this help is awesome), but a few remain:

chris fatal error LNK1120: 1 unresolved externals

chris error LNK2019: unresolved external symbol _main referenced in function _mainCRTStartup

round two

Share on other sites
polisasimo    158
I did create a Win32console project, I have included the #include <winalleg.h> line but....

allegro error LNK2019: unresolved external symbol _main referenced in function _mainCRTStartup
allegro fatal error LNK1120: 1 unresolved externals

(I created a new project just to be safe that is why the chris is now allegro)

Hrmpph

Share on other sites
Drew_Benton    1861
Ok had to look this one up:
#define USE_CONSOLE

And it will compile. You do not need the Winalleg.h after all. This problem has came up before, but I don't think the answer was ever found. Here is the reference link for you.

Share on other sites
Try changing that
return(0);
to an
allegro_exit();

Share on other sites
polisasimo    158
Drew you are the master. Thanks also to hothead.

I am a CS140 student going way over my head considering I have just learned what a call by reference function is :)

Just out of curiosity are you guys or gals programmers by trade, if so how is the job market?

Share on other sites
Drew_Benton    1861
Also, you should do as Hothead has asid about the return [wink]. It's a little more proper *I think*/*hope* [lol]. I'm a freshman in college now - so programming is my hobby/trade/life etc.... I hope the job market is good when I get out - if not more the reason to start my own co. if I am not already doing something [smile]

Share on other sites
polisasimo    158
Sorry you guy are having to walk me through this but one more question:

new code:

#define USE_CONSOLE#include <allegro.h> // You must include the Allegro Header file int main(int argc, char argv[]){	BITMAP *my_pic;	allegro_init(); // Initialize Allegro	install_keyboard(); // Initialize keyboard routines									set_color_depth(16); // Set the color depth	set_gfx_mode(GFX_AUTODETECT, 640,480,0,0); // Change our graphics mode to 640x480	my_pic = load_bitmap(C:\Documents and Settings\Owner\My Documents\Visual Studio Projects\allegro\pic.bmp, NULL); // Load our picture	acquire_screen();	blit(my_pic, screen, 0,0,0,0,480,360);//Draw the whole bitmap to the screen at (0,0)	release_screen();	destroy_bitmap(my_pic);//Release the bitmap data	readkey();// Wait untill a key is pressed	return(0);// Exit with no errors}END_OF_MAIN(); // This must be called right after the closing bracket of your MAIN function.               // It is Allegro specific.

I think my file location has problems because this should output a small picture but alas the screen is black and th program crashes.

Share on other sites
I commented what I fixed:
#define USE_CONSOLE#include <allegro.h> // You must include the Allegro Header file int main(int argc, char argv[]){	BITMAP *my_pic;	allegro_init(); // Initialize Allegro	install_keyboard(); // Initialize keyboard routines									set_color_depth(16); // Set the color depth	set_gfx_mode(GFX_AUTODETECT, 640,480,0,0); // Change our graphics mode to 640x480	my_pic = load_bitmap("tehred.bmp", NULL); // HERE.	acquire_screen();	blit(my_pic, screen, 0,0,0,0,480,360);//Draw the whole bitmap to the screen at (0,0)	release_screen();	destroy_bitmap(my_pic);//Release the bitmap data	readkey();// Wait untill a key is pressed	return(0);// Exit with no errors}END_OF_MAIN(); // This must be called right after the closing bracket of your MAIN function.               // It is Allegro specific.

tehred.bmp being a picture I drew myself.
That should work.

Share on other sites
polisasimo    158
Sorry man I continue to get just a black screen. While in this screen my initail keyboard input that should end program does not work and then I get the ever so lovely microsoft allegro.exe has encountered an error and needs to shut down .... would you like to send the error report.

Share on other sites
Hmm, works fine for me.Did you try putting the image inside your VC++ zip?

Share on other sites
polisasimo    158
Wow!!! my fault I was typing in the entire location of the file c:\blahblahblah instead of just the name I have got it working now.

thanks