Sign in to follow this  
_GLoom_

[GBA] Problem accessing a bitmap

Recommended Posts

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 <stdlib.h>
#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<160; y++)
    for(x=0; x<240; x++)
        DrawPixel_M3(x, y, GBA_TEST_Bitmap[y * 240 + x]);
...
...
}

Any help will be appreciated :)

Share this post


Link to post
Share on other sites
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 this post


Link to post
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 this post


Link to post
Share on other sites
Quote:
Original post by rick_appleton
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[];


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!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this