# [GBA] Problem accessing a bitmap

## Recommended Posts

_GLoom_    122
I'm reading the book on JHarbour.com as well, and I just got to start working with bitmaps but I'm getting a 'multiple definition error' and I suspect it's pretty easy to solve but I don't know what's the problem. gfx2gba seems to have worked ok. I get this error on Visual Ham output window:
GBA_TEST.raw.o(.rodata+0x0): multiple definition of GBA_TEST_Bitmap'
main.o(.rodata+0x0): first defined here


And I see these other files were created on the same directory GBA_TEST.raw.c is:
GBA_TEST.raw.i
GBA_TEST.raw.o
GBA_TEST.raw.s


This is what the code looks like:
#include &lt;stdlib.h&gt;
#include "GBA_TEST.raw.c"

void DrawPixel_M3(int, int, unsigned short);

#define REG_DISPCNT *(unsigned long*)0x4000000
#define MODE_3 0x3
#define BG2_ENABLE 0x400

#define SetMode(mode) REG_DISPCNT = (mode)

unsigned short* videoBuffer = (unsigned short*)0x6000000;

int main(void)
{
int x, y;

SetMode(MODE_3 | BG2_ENABLE);

for(y=0; y&lt;160; y++)
for(x=0; x&lt;240; x++)
DrawPixel_M3(x, y, GBA_TEST_Bitmap[y * 240 + x]);
...
...
}


Any help will be appreciated :)

##### Share on other sites
Toolmaker    967
By the looks of your code, it would seem to me that in the GBA_TEST.raw.c file the GBA_TEST_Bitmap variable is defined multiple times.

Could you post the contents of the GBA_TEST.raw.c file?

Toolmaker

##### Share on other sites
Or rather, it looks like the data is in GBA_TEST.raw.c, and since that file is compiled as well as main.o, it's defined twice.

You have two options:
1) Don't compile GBA_TEST.raw.c itself. Since it's included in main.c it'll be compiled there. This option might not be easy depending on how your Makefile is structured.
2) Don't include GBA_TEST.raw.c but GBA_TEST.raw.h in your main file. This assumes that GBA_TEST.raw.h actually exists and has the variable you want to access extern'd. Like so (example, adjust to suit):
extern u16 GBA_TEST_Bitmap[];

##### Share on other sites
_GLoom_    122
Quote:
 Original post by rick_appletonOr rather, it looks like the data is in GBA_TEST.raw.c, and since that file is compiled as well as main.o, it's defined twice.You have two options:1) Don't compile GBA_TEST.raw.c itself. Since it's included in main.c it'll be compiled there. This option might not be easy depending on how your Makefile is structured.2) Don't include GBA_TEST.raw.c but GBA_TEST.raw.h in your main file. This assumes that GBA_TEST.raw.h actually exists and has the variable you want to access extern'd. Like so (example, adjust to suit):extern u16 GBA_TEST_Bitmap[];`

Thanks for your replies, option #2 did the trick just great!! I hadn't thought that since GBA_TEST.raw.c is compiled as well, when I include it on 'main' it's already defined.
Thanks a lot, now I continue reading that great book while I'm supposed to be doing some DB changes here at work hehehe.

Thanks rick_appleton!