Allegro errors during tutorial?

Started by
14 comments, last by polisasimo 19 years ago
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
	use in your program.

    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]
Advertisement
Your code looks fine to me.Try linking these in the linker from projects-> project options
-lalleg_s -lgdi32 -ldxguid -lole32 -ldinput -lddraw -lwinmm -ldsound
and this in the C++ compiler from projects->project options
-DALLEGRO_STATICLINK

If you still get errors; download the DirectX dev-pak.
-----------------------------------Panic and anxiety Disorder HQ
[edit] 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]
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
advanced
command line

am I on the right track

ps thanks so far
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.
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
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
Ok had to look this one up:
Above your include file, add:
#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.
Try changing that
return(0);
to an
allegro_exit();

-----------------------------------Panic and anxiety Disorder HQ
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?

This topic is closed to new replies.

Advertisement