Qbasicnews.com

Full Version: Allegro help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, I'm new here, but I need some help. I'm trying to use Allegro in my program, and to keep everything neat, I have a series of wrapper subs like "DrawText(txt as string, x as integer, y as integer)'

Anyway, due to the setup of my program, I use a Makefile which compiles each .bas file into a .o file, then links 'em together. It compile the source fine, but when it links, it gives me this error:

Code:
c:\temp\freebasic\fbc  -x game.exe new-game.o graphics.o
graphics.o(.text+0x57):fake: undefined reference to `install_allegro'
graphics.o(.text+0x61):fake: undefined reference to `set_color_depth'
graphics.o(.text+0x79):fake: undefined reference to `set_gfx_mode'
graphics.o(.text+0x81):fake: undefined reference to `install_keyboard'
graphics.o(.text+0x91):fake: undefined reference to `install_sound'
graphics.o(.text+0xb7):fake: undefined reference to `vsync'
graphics.o(.text+0xdd):fake: undefined reference to `acquire_bitmap'
graphics.o(.text+0xfd):fake: undefined reference to `release_bitmap'
graphics.o(.text+0x139):fake: undefined reference to `textout'
graphics.o(.text+0x158):fake: undefined reference to `_imp__font'
graphics.o(.text+0x2cb):fake: undefined reference to `set_palette'

I read somewhere that the "fake" part means that it can't find a library to link in with it, but it's included and everything. I have another program that works fine compiling and linking with allegro, so I have no clue what's wrong... help?
Well, I managed to kludge it. I manually told the fbc to link in liballeg.dll.a (by adding "-l alleg.dll" to the link command line).

I'm still curious as to why it's not doing this by itself, though...
You mean you are compiling and static library/collection of objects that call Allegro and next passing them on command-line when compiling an exe that uses your wrapper?

Sure, you have add the external libs by hand when doing that, the libs called won't be saved to the obj files (the GNU linker does not support the M$ directives). If you have an include file you are using for your wrapper, you can add a #inclib "alleg" to it, that tells fbc to pass that lib to linker's command-line.
Oooh... duh... :oops: I feel very foolish.

It's set up so that each .bas is compiled into a .o, then the .o's are linked together into a .exe (I do all this with fbc). It save tile re-compiling, since make only re-does the changed .bas files.

Anyway, I'm not making a wrapper. I meant that I abstracted, say, all the graphics calls into "graphics.bas". Then, I just call the subs in graphics.bas to draw stuff to the screen. I'm making a self-contained program.

So, thanks for the (obvious) help. Hope to see v.13 soon!