linker error:arready difined
well, i declare some globals in a header, and then i intend to use them in the code, but when i get to the linker, it gives me this error,
TricksMainGame.obj : error LNK2005: "struct HINSTANCE__ * hinstance_app" (?hinstance_app@@3PAUHINSTANCE__@@A) already defined in TricksInti.obj
TricksMainGame.obj : error LNK2005: "struct HWND__ * main_window_handle" (?main_window_handle@@3PAUHWND__@@A) already defined in TricksInti.obj
it gives it to me twice, i have 3 cpp files and i gives it to me 1 time for each, never gets to the other files)
i can't of declared it more i then once(i looked, + the app is an empty shell right now, there is only some windows setup code and a few functions that have nothing in them.)
here is where i the stuff in the .h
extern HWND main_window_handle = NULL; // globally track main window
extern HINSTANCE hinstance_app = NULL; // globally track hinstance
[edited by - headshot on July 28, 2003 2:17:48 PM]
quote:Original post by headshot
well, i declare some globals in a header, and then i intend to use them in the code, but when i get to the linker, it gives me this error,
extern HWND main_window_handle = NULL; // globally track main window
extern HINSTANCE hinstance_app = NULL; // globally track hinstance
[edited by - headshot on July 28, 2003 2:17:48 PM]
Should this NOT be:
In header file:
extern HWND main_window_handle ; // globally track main windowextern HINSTANCE hinstance_app ; // globally track hinstance
In source file:
HWND main_window_handle = NULL; // globally track main windowHINSTANCE hinstance_app = NULL; // globally track hinstance
defined globally of course.
See ''Header Files'' link in my signature.
[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]
[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]
quote:Original post by Fruny
See ''Header Files'' link in my signature.
[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]
Can''t agree more with Fruny.
THanks for the pointer to the excellent article.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement