MSVC Linkage crapitute.

Started by
2 comments, last by Clash Rocker 23 years, 1 month ago
Ofcourse my output: ******** --------------------Configuration: OMF CHR EDITOR - Win32 Debug-------------------- Compiling... main.cpp uops.cpp Linking... uops.obj : error LNK2005: "char * g_sProgramTitle" (?g_sProgramTitle@@3PADA) already defined in main.obj uops.obj : error LNK2005: "struct COMMONDATA g_ComData" (?g_ComData@@3UCOMMONDATA@@A) already defined in main.obj uops.obj : error LNK2005: "void * g_hSvGmFile" (?g_hSvGmFile@@3PAXA) already defined in main.obj uops.obj : error LNK2005: "struct HINSTANCE__ * g_hInstMain" (?g_hInstMain@@3PAUHINSTANCE__@@A) already defined in main.obj uops.obj : error LNK2005: "struct RAWCHR g_RawPilots" (?g_RawPilots@@3URAWCHR@@A) already defined in main.obj uops.obj : error LNK2005: "char * g_sSavedGame" (?g_sSavedGame@@3PADA) already defined in main.obj uops.obj : error LNK2005: "short g_CurrPilot" (?g_CurrPilot@@3FA) already defined in main.obj uops.obj : error LNK2005: "void * g_hTempFile" (?g_hTempFile@@3PAXA) already defined in main.obj uops.obj : error LNK2005: "int g_GenralTruth" (?g_GenralTruth@@3HA) already defined in main.obj main.obj : error LNK2001: unresolved external symbol __imp__InitCommonControls@0 main.obj : error LNK2001: unresolved external symbol "int __cdecl DoData(struct HWND__ *,short)" (?DoData@@YAHPAUHWND__@@F@Z) main.obj : error LNK2001: unresolved external symbol "int __cdecl DoFiles(struct HWND__ *)" (?DoFiles@@YAHPAUHWND__@@@Z) main.obj : error LNK2001: unresolved external symbol "int __cdecl DoSavedGame(struct HWND__ *)" (?DoSavedGame@@YAHPAUHWND__@@@Z) main.obj : error LNK2001: unresolved external symbol "void __cdecl DoCtrls(struct HWND__ *)" (?DoCtrls@@YAXPAUHWND__@@@Z) Debug/OMF CHR EDITOR.exe : fatal error LNK1120: 5 unresolved externals Error executing link.exe. OMF CHR EDITOR.exe - 15 error(s), 0 warning(s) ******** Ok, main.cpp -> main.obj is the well, the main part of my program. Program entry, it includes main.h uops.cpp -> uops.obj is just funtions, it also includes main.h Now in main.h is some global vars and a functino decs. I decided to some funtion defs in another file: uops, I did this by File - New and selected new source file and "add to project." And thats when the I get the linker errors The linker complains about global vars. I''ve tried putting extern at the top of the other .cpp file, but it doesn''t help...I''m stuck. I don''t know if I should post my code...Its big and I don''t know which part(s) to post. If anyone can help me, I''d be...happy I guess. Thanks. One Must Fall :2097 - The 2D classic :Battlegrounds - The 3D version www.omf.com
Advertisement
Have you made sure that the contents of main.h are only being compiled once?

Try putting something like this at the top of main.h:

#ifndef __MAIN_HEADER__
#define __MAIN_HEADER__

and at the end, put:

#endif

Hope that helps
-----------------------"When I have a problem on an Nvidia, I assume that it is my fault. With anyone else's drivers, I assume it is their fault" - John Carmack
Ah nuts!
Yeah I do have an inclusion guard, **** sorry about leaving
that detail out *slaps himself*

I appricate the help thou

One Must Fall
:2097 - The 2D classic
:Battlegrounds - The 3D version
OMF

Don''t define variables in header files. Give an extern definition of them, so any file including that header knows that they exist, and actually define them (including initialisation) in a .cpp file.

This topic is closed to new replies.

Advertisement