🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Just started out with Allegro, few problems.

Started by
2 comments, last by HackMaster321 19 years, 11 months ago
Ok, so, I've played a bit with OpenGL, Direct3D and some SDL before, so I thought "why not try Allegro?". It looks simple enough, and fun to use, so yes, I decided to give it a shot. I downloaded the precompiled binaries for MinGW, made a MINGDIR variable like I was told in the tutorials, and ran install.bat (actually, I first copied it all by hand, but install.bat just over wrote everything). I have the 3 Allegro DLL's in System and System32, but I doubt that could be giving me the problem I'm having. I might as well paste the code I've typed out (very simple, just to test Allegro):
#include <allegro.h>

int main(int argc, char *argv[]) 
{         
	
	allegro_init();
	install_keyboard();         
	set_gfx_mode(GFX_AUTODETECT, 640,480,0,0);
	readkey();       
	return (0);     

}     
END_OF_MAIN();
Now, that should work just fine and dandy from what I've read, but I come up with these errors:
C:\>gcc -o allegrotest allegrotest.c
C:\DOCUME~1\Owner\LOCALS~1\Temp/ccEtaaaa.o(.text+0x1d):allegrotest.c: undefined
reference to `install_allegro'
C:\DOCUME~1\Owner\LOCALS~1\Temp/ccEtaaaa.o(.text+0x25):allegrotest.c: undefined
reference to `install_keyboard'
C:\DOCUME~1\Owner\LOCALS~1\Temp/ccEtaaaa.o(.text+0x3d):allegrotest.c: undefined
reference to `set_gfx_mode'
C:\DOCUME~1\Owner\LOCALS~1\Temp/ccEtaaaa.o(.text+0x45):allegrotest.c: undefined
reference to `readkey'
C:\DOCUME~1\Owner\LOCALS~1\Temp/ccEtaaaa.o(.text+0x6b):allegrotest.c: undefined
reference to `_WinMain'
I have everything where it belongs, so what's the problem? Did I forget to link something (I didn't link anything)? I'm quite perplexed, any help would be much appreciated. Thanks in advance. [smile]
_________________Politics is the ability to foretell what is going to happen tomorrow, next week, next month and next year. And to have the ability afterwards to explain why it didn't happen. -- Winston ChurchillGDNet-0.2 - rate users the easy way with this nifty Firefox extension. Updated with new features.
Advertisement
Alright, so I'm stupid, it turns out I forgot -l alleg.

I was issuing the command:
gcc allegrotest.c -o allegrotest

(or in a different order, doesn't matter)
when I should have been issuing this command:
gcc allegrotest.c -o allegrotest.exe -l alleg

Now, the .exe isn't necessary, but I'm glad I got it all working.

[smile]
_________________Politics is the ability to foretell what is going to happen tomorrow, next week, next month and next year. And to have the ability afterwards to explain why it didn't happen. -- Winston ChurchillGDNet-0.2 - rate users the easy way with this nifty Firefox extension. Updated with new features.
You might want to write a makefile, something like this:

#all isn't a file.PHONY: all# list all the programs you want to compile. Since all is the first real target# in this makefile, make will try to create everything if you don't tell it what to make.all: program.exe# Tell make how to make an object file.# $< is the name of the source file, $@ is the name of the object file.# -Wall tells the compiler to issue warnings.# -O3 tells the compiler to optimize. If you want to do debugging, remove# it and add -g3 instead.%.o: %.c	gcc -c -O3 -Wall $< -o$@# The above line begins with a tab character. This is important, don't replace it with spaces!# Tell make how to create an executable.# $^ is all the files the program depends on, and $@ is the name of the program.# -s tells the compiler to remove unless things from the final program. If you're# going to be debugging, remove it, because it will remove the debugging information.%.exe:	gcc -s $^ -o$@ -lalleg# The above line also begins with a tab character.# Finally, we'll tell make what object files the executables need.program.exe: main.o foo.o bar.o

You'd just stick that in a file named 'Makefile', and after that you'd just need to type 'make' to compile your program. I'm just saying this because it looks like you're not using an IDE, and typing out those long commands gets tiresome after a while.
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other player's eyes with his King.
i would reccomend bloodshed dev c++ as a good ide, it comes with a devpak(add on thing) for allegro, really good, my personal favourite. I didnt think there were many people using allegro, it doesnt seem as popular as sdl, but I use it a lot.. thats my 3 and 1/2 cents
---------------Full Time Musician: Staggerin' Monks

This topic is closed to new replies.

Advertisement