Advertisement

Allegro Problems

Started by July 25, 2004 05:52 PM
10 comments, last by hellz 20 years, 4 months ago
Hi, I started playing around with Allegro today, and I'm having problems compiling programs. Allegro looks to be installed correctly. I'm using Allegro 4.0.3 and Visual Studio .NET. I've got C:\Program Files\Allegro\include in the directory settings for the project (which is a C++ win32 console project) and C:\Program Files\Allegro\lib\msvc for the libraries, yet after trying to compile the following code, I get a lot of warnings and linker errors:

// First tutorial from http://agdn.cjb.net
#include <allegro.h>

int main()
{
	int done = false;
	allegro_init();
	install_keyboard();

	set_color_depth(16);
	if (set_gfx_mode(GFX_AUTODETECT, 800, 600, 0, 0) < 0)
	{
		set_color_depth(15);
		if (set_gfx_mode(GFX_AUTODETECT, 800, 600, 0, 0) < 0)
		{
			allegro_message("Unable to initialise graphics module\n%s\n", allegro_error);
			return -1;
		}
	}

	acquire_screen();
	textout(screen, font, "Hello, world!", 100, 100, makecol(255, 255, 255));
	release_screen();

	while (!done)
	{
		if (key[KEY_ESC]) done = true;
	}

	return 0;
}
END_MAIN();

Now here are the warnings and errors: Compiling... main.cpp c:\Program Files\Allegro\include\allegro\internal\alconfig.h(296) : warning C4312: 'type cast' : conversion from 'unsigned long' to 'unsigned char *' of greater size c:\Program Files\Allegro\include\allegro\internal\alconfig.h(303) : warning C4312: 'type cast' : conversion from 'unsigned long' to 'unsigned char *' of greater size c:\Program Files\Allegro\include\allegro\inline\draw.inl(251) : warning C4312: 'type cast' : conversion from 'unsigned long' to 'unsigned char *' of greater size c:\Program Files\Allegro\include\allegro\inline\draw.inl(265) : warning C4312: 'type cast' : conversion from 'unsigned long' to 'unsigned char *' of greater size c:\Program Files\Allegro\include\allegro\inline\draw.inl(276) : warning C4312: 'type cast' : conversion from 'unsigned long' to 'unsigned short *' of greater size c:\Program Files\Allegro\include\allegro\inline\draw.inl(290) : warning C4312: 'type cast' : conversion from 'unsigned long' to 'unsigned short *' of greater size c:\Program Files\Allegro\include\allegro\inline\draw.inl(301) : warning C4312: 'type cast' : conversion from 'unsigned long' to 'unsigned short *' of greater size c:\Program Files\Allegro\include\allegro\inline\draw.inl(315) : warning C4312: 'type cast' : conversion from 'unsigned long' to 'unsigned short *' of greater size c:\Program Files\Allegro\include\allegro\inline\draw.inl(351) : warning C4312: 'type cast' : conversion from 'unsigned long' to 'unsigned long *' of greater size c:\Program Files\Allegro\include\allegro\inline\draw.inl(365) : warning C4312: 'type cast' : conversion from 'unsigned long' to 'unsigned long *' of greater size Linking... main.obj : error LNK2001: unresolved external symbol __imp__key main.obj : error LNK2019: unresolved external symbol __imp__release_screen referenced in function "int __cdecl _mangled_main(void)" (?_mangled_main@@YAHXZ) main.obj : error LNK2019: unresolved external symbol __imp__textout referenced in function "int __cdecl _mangled_main(void)" (?_mangled_main@@YAHXZ) main.obj : error LNK2001: unresolved external symbol __imp__screen main.obj : error LNK2001: unresolved external symbol __imp__font main.obj : error LNK2019: unresolved external symbol __imp__makecol referenced in function "int __cdecl _mangled_main(void)" (?_mangled_main@@YAHXZ) main.obj : error LNK2019: unresolved external symbol __imp__acquire_screen referenced in function "int __cdecl _mangled_main(void)" (?_mangled_main@@YAHXZ) main.obj : error LNK2019: unresolved external symbol __imp__allegro_message referenced in function "int __cdecl _mangled_main(void)" (?_mangled_main@@YAHXZ) main.obj : error LNK2001: unresolved external symbol __imp__allegro_error main.obj : error LNK2019: unresolved external symbol __imp__set_gfx_mode referenced in function "int __cdecl _mangled_main(void)" (?_mangled_main@@YAHXZ) main.obj : error LNK2019: unresolved external symbol __imp__set_color_depth referenced in function "int __cdecl _mangled_main(void)" (?_mangled_main@@YAHXZ) main.obj : error LNK2019: unresolved external symbol __imp__install_keyboard referenced in function "int __cdecl _mangled_main(void)" (?_mangled_main@@YAHXZ) main.obj : error LNK2019: unresolved external symbol __imp__install_allegro referenced in function "int __cdecl _mangled_main(void)" (?_mangled_main@@YAHXZ) LIBCD.lib(crt0.obj) : error LNK2019: unresolved external symbol _main referenced in function _mainCRTStartup Debug/Basic.exe : fatal error LNK1120: 14 unresolved externals Build log was saved at "file://d:\My Documents\GameDev\Allegro\Basic\Debug\BuildLog.htm" Basic - 15 error(s), 10 warning(s) ---------------------- Done ---------------------- Build: 0 succeeded, 1 failed, 0 skipped I really expected the problem to be with the extra include/library directories needed for the probject, but being as I already have those, I'm a little lost. Could anyone lend me a hand please? -hellz
Well, make absolutely sure you're linking with liballeg.a. That would be my first guess why you're getting linking errors. [smile]

Those warnings you got are normal for VC.NET and allegro. I think you can hide those warnings by using #pragma warning( disable : 4312 ).
I don't use VC.NET though, so don't quote me. [smile]

Jesus saves ... the rest of you take 2d4 fire damage.

Advertisement

Use #pragma to hide the warnings and use a Win32 Application (not console) when setting up the project to get rid of the errors.

For more information see:

* MSVC 7 Setup Guide
* Previous Threads with the same problem
Thank you very much for taking the time to reply! There are less problems now, but it's still having problems resolving the entry point, whether it's a Win32 or a console application. Also, when attempting to link with liballeg.a, it just tells me it can't find it, which tells me something else is wrong.

The only files I've got in the lib directory, are as follows:

aldat.lib
alld.exp
alld.lib
alld40.def
alld40.dll
alleg.exp
alleg.lib
alleg40.def
alleg40.dll
allegro.def
allp.exp
allp.lib
allp40.def
allp40.dll

OK, I think I'd best head over to those other forums and have a read now. Thanks again for replying to me, and if I find a solution, I'll post back with the info. =)

-hellz
Please follow the guide there, it really does take you step by step in setting up Allegro.

Quote: Also, when attempting to link with liballeg.a

You don't link with liballeg.a if you are using MSVC. You link with alleg.lib.
Quote: Original post by konForce
You don't link with liballeg.a if you are using MSVC. You link with alleg.lib.

And this is why I said "don't quote me". [embarrass]
Should have stuck with "RTFM!!1". [wink]

Jesus saves ... the rest of you take 2d4 fire damage.

Advertisement
Quote: Original post by konForce
Please follow the guide there, it really does take you step by step in setting up Allegro.

Quote: Also, when attempting to link with liballeg.a

You don't link with liballeg.a if you are using MSVC. You link with alleg.lib.


My fault, I should've made this a little clearer. Following the guide still left the error with the main/WinMain functions. That's why I decided to try linking with liballeg.a instead of alleg.lib, just to see if it made any difference. =)

Again, thank you for the response, but I just wanted to clear that up. =) I'll keep playing with it and see what happens. :D

-hellz
Getting closer! Turns out the extraction of Allegro must have screwed up somewhere. The Release and Profile configurations worked, but the Debug (active) didn't. Had a look at the projects, but the settings seemed right. So I had a quick look at the directories, and the alld.lib was 0k. Replaced it with a fresh copy and it all compiles fine now. =)

However... when I try to run the debug build (only the debug build), I get the following error dialog:

Test.exe - Unable To Locate DLL

The dynamic link library MSVCRTD.dll could not be found in the specified path, yadda yadda.

So I had a look around on my system and it's not there at all. Is this DLL just related to debugging C++ applications? I don't have any problems with debugging C# ones.

Again, thank you very much for the assistance you've provided me.

-hellz
There is a debug Allegro DLL, not sure if it would help you ...

Jesus saves ... the rest of you take 2d4 fire damage.

Thanks dude, I'll check that out. I'm thinking MSVCRTD.DLL is the Microsoft C Runtime Library Debug DLL (at a guess), and if that's the case, I've got Visual Studio 6 on CD as well, so I'll nab it from that.

Cheers again guys, all is well. =)

-hellz

This topic is closed to new replies.

Advertisement