Skip to main content
GameDev.net gamedev.net
🔒 Locked

Help Help! Compiler Errors!

Started by AmmoSponge Apr 11, 2001 at 9:37 PM 6 replies 800+ views
Original Post
AmmoSponge
AmmoSponge
Help help! I havent been able to get past a basic framework for the game I am working on because it wont link. All the individual objects compile fine but it gives me the following every time it reaches the linker: --------------------Configuration: Project 1 - Win32 Debug-------------------- Compiling... main.cpp Linking... LoadBitmap.obj : error LNK2005: "struct IDirectDrawClipper * lpClipper" (?lpClipper@@3PAUIDirectDrawClipper@@A) already defined in DirectDraw.obj LoadBitmap.obj : error LNK2005: "struct IDirectDrawSurface7 * lpBack" (?lpBack@@3PAUIDirectDrawSurface7@@A) already defined in DirectDraw.obj LoadBitmap.obj : error LNK2005: "struct IDirectDrawSurface7 * lpPrimary" (?lpPrimary@@3PAUIDirectDrawSurface7@@A) already defined in DirectDraw.obj LoadBitmap.obj : error LNK2005: "struct IDirectDraw7 * lpDD7" (?lpDD7@@3PAUIDirectDraw7@@A) already defined in DirectDraw.obj main.obj : error LNK2005: "struct IDirectDrawClipper * lpClipper" (?lpClipper@@3PAUIDirectDrawClipper@@A) already defined in DirectDraw.obj main.obj : error LNK2005: "struct IDirectDrawSurface7 * lpBack" (?lpBack@@3PAUIDirectDrawSurface7@@A) already defined in DirectDraw.obj main.obj : error LNK2005: "struct IDirectDrawSurface7 * lpPrimary" (?lpPrimary@@3PAUIDirectDrawSurface7@@A) already defined in DirectDraw.obj main.obj : error LNK2005: "struct IDirectDraw7 * lpDD7" (?lpDD7@@3PAUIDirectDraw7@@A) already defined in DirectDraw.obj main.obj : error LNK2005: "struct HINSTANCE__ * hinstance_app" (?hinstance_app@@3PAUHINSTANCE__@@A) already defined in DirectDraw.obj main.obj : error LNK2005: "struct HWND__ * main_window_handle" (?main_window_handle@@3PAUHWND__@@A) already defined in DirectDraw.obj main.obj : error LNK2005: "bool active_app" (?active_app@@3_NA) already defined in DirectDraw.obj LoadBitmap.obj : error LNK2001: unresolved external symbol _DDLoadBitmap Debug/Project 1.exe : fatal error LNK1120: 1 unresolved externals Error executing link.exe. Project 1.exe - 13 error(s), 0 warning(s) ---------------------------------------------------------------------------- I have the source zipped up and ready to be added to a project. It even includes a bitmap to output if it can get correctly linked. I tried using extern #ifndef #define and #including the headers in all sorts of different places. I think I am getting the errors because my Globals.h is being included in multiple files even though it shouldnt. code is at http://filebox.vt.edu/users/mijohn12/ProblemCode.zip Help me code-monkeys. You are my only hope.
Cyberdrek
Cyberdrek
in your Globals.h file, try putting at the beginning of the file. IE: first & second lines:

  
#ifndef GLOBALS_H
#define GLOBALS_H
// your global stuff here...

#endif


this should solve your problems. If not, I don''t know what the problem might be...



"And that''s the bottom line cause I said so!"

Cyberdrek
Headhunter Soft
A division of DLC Multimedia

Resist Windows XP''s Invasive Product Activation Technology!
[Cyberdrek | ]
AmmoSponge
AmmoSponge
I have the #ifndef GLOBALS_H and #define GLOBALS_H and #endif in the Globals.h file. Yet it still doesnt work.
Dont believe me?
source -> http://filebox.vt.edu/users/mijohn12/ProblemCode.zip
thanks for the reply though
when i posted before no one even bothered
Blackstream
Blackstream
You are scaring me, that is almost the exact same errors I got and bashed my head over. My problem was that a) I didn''t include winmm.lib, and b) I had #define INITGUID twice total in all of my source files. Apparently it can only be defined once. Make sure neither of those are the case. Hmmm, I''ll take a look at yer code and see what else could be up.

-Blackstream

Will you, won''t you, will you, won''t you, won''t you take my virus?

-The Mad Hacker

Blackstream''s Webpage
-Blackstream Will you, won't you, will you, won't you, won't you take my virus?-The Mad HackerBlackstream's Webpage
Blackstream
Blackstream
I looked though your code, I can''t really find anything that would do that. Your ddutil.h file may be included more than once, I''d put the #ifndef stuff around ddutil.h as well.

-Blackstream

Will you, won''t you, will you, won''t you, won''t you take my virus?

-The Mad Hacker

Blackstream''s Webpage
-Blackstream Will you, won't you, will you, won't you, won't you take my virus?-The Mad HackerBlackstream's Webpage
AmmoSponge
AmmoSponge
Well thanks for looking.
I will try moving ddutil.h inside the #ifndef but I think i already tried that and it didnt help. I noticed you said something about winmmlib. I didnt have that included in my code at all and I didnt #define INTGUID either. Could that be the problem? Where do I put them if I DO need them?
Thanks
NightShade
NightShade
Hi!

I think what you need to do is, in globals.h, just *declare* everything. In other words, instead of having:
LPDIRECTDRAW7 lpDD7 = NULL;

have:
extern LPDIRECTDRAW7 lpDD7;

Then, somewhere else (e.g. a file globals.cpp, but really it could be any cpp file), have the actual definitions and initialization:
LPDIRECTDRAW7 lpDD7 = NULL;

I think the problem now is that, for each cpp file, it includes globals.h, which has the definition. You end up with many .obj files, each with the definition of the same data, and the linker has a nervous breakdown trying to deal with it all. What you want is one copy of that data, and you can just tell all your code about it with declarations in an H file.

Hope ths helps!





-ns-
-ns-
python_regious
python_regious
NightShade is right, to use the same var in multiple source files, you need to declaire it as external in the header file, then declaire it normally in one of the source files. ( vars.cpp or something ).
If at first you don't succeed, redefine success.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.