gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Beginners > Compiling images and linking

#23286 - krozen - Fri Jul 09, 2004 12:56 pm

Hello,
I was just wondering. I have a few large image arrats. Rather than #include them, i compiled them as .o files, and was goin to link them in at the end, to save compile time, which currently takes ages. How do i link them in with the final code file that draws these images to the screen. Every time i try it i get errors because the main file complains that the images havent been declared yet etc....
Thanks guys
Damien

#23291 - poslundc - Fri Jul 09, 2004 2:18 pm

Create a .h file that declares references to your external data, eg.

extern const u16 mySpriteData[];

Essentially just take the declaration lines for your data objects from their respective .c files, add an "extern" at the beginning and a semicolon at the end.

Then #include this header file in any C program that needs to access your linked data.

(You can, obviously, break this into multiple header files if you prefer to have one for each sprite, for example.)

Dan.

#23298 - krozen - Fri Jul 09, 2004 3:36 pm

that worked great! thanks, you just saved me sooo much waitin around! now i have the time to do all the things i ever wanted...like...wait...i dont have anything else to do.....nooo.....damn you!!! :) thanks again!