From graphics.cpp
| 1 | #include "allegro.h" |
| 2 | #include "graphics.h" |
| 3 | |
| 4 | graphicssystem gfx; |
| 5 | |
| 6 | // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
| 7 | void graphicssystem::loadcharacter(int whichcharacter) |
| 8 | { |
| 9 | switch(whichcharacter) |
| 10 | { |
| 11 | case UNDEAD2: |
| 12 | // Load standing "animation" |
| 13 | undead[0].sprite = load_bitmap("graphics\\32x64.bmp",undead[0].palette); |
| 14 | undead[0].width = 32; |
| 15 | undead[0].height = 64; |
| 16 | undead[0].totalframes = 1; |
| 17 | break; |
| 18 | default: |
| 19 | allegro_message("ERROR\n\nIt seems we're trying to load a character which doesn't exist!\n\nOh dear."); |
| 20 | break; |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | ... |
From graphics.h
The above generates the following error from Visual Studio
graphics.obj : error LNK2019: unresolved external symbol "struct charactersprite * undead" (?undead@@3PAUcharactersprite@@A) referenced in function "public: void __thiscall graphicssystem::loadcharacter(int)" (?loadcharacter@graphicssystem@@QAEXH@Z)
undead.exe : fatal error LNK1120: 1 unresolved externals
I've also attached the entire graphics.cpp and graphics.h files as they stand right now, should anyone want to see more.
Can anyone please let me know why that error comes up? It seems very mysterious to me, as the .h file is included and the thing is global.
Oh, and I looked up the Microsoft help for that error. It says this code should generate that error as well, but I don't know why either.
// LNK2019.cpp // LNK2019 expected extern char B[100]; // B is not in avilable to the linker int main() { B[0] = ' '; }
(Yes, that misspelling was part of it.) Why would B not be available to the linker? It's right there. I know, that's simplistic reasoning but at this point I just don't understand this. I've tried removing extern, I've tried moving the declaration to the .cpp file. All with no luck.
Thanks for any help.
Edit: Thanks X-G. File now uploaded.
I've also attached the entire graphics.cpp and graphics.h
No you haven't. Besides, your problem is that you haven't defined undead for real anywhere, just an extern declaration.
Got it. Added
struct charactersprite undead[15];
to graphics.cpp
Thanks!