Error when compiling

Started by
6 comments, last by p4n1c 21 years, 7 months ago
I get this error whenever trying to link my executable: m_camera.obj : error LNK2005: _SinT already defined in m_vid.obj That is just one. I have about 12 and it relates to a lot of the globals I have in my header files. Is there anyway to get rid of these errors?
-----For I have seen the face of evil and it will not soon be forgotten.
Advertisement
You probably have a lot of conflicting definitions of functions, probably due to weird inclution of files. Please list what files are in your project and which files each of them include.
m_camera.cpp
------------
m_camera.h which in turn includes math3d.h

m_vid.cpp
---------
m_vid.h - which loads up windows.h as well(for the globals in it)
m_camera.h
stdio.h
gl/gl.h
gl/glu.h

m_win32.cpp
-----------
m_vid.h
-----For I have seen the face of evil and it will not soon be forgotten.
if they are redefninitions (defined twice) either get rid of them or place the "extern" keyword in front of them.
You are sure that you don't define any functions in your header files, only declare them there? I cannot spot a clear error here, so I ask you to post the entire compile log with all errors.

EDIT: Btw, what header file is math3d.h?

[edited by - CWizard on September 2, 2002 8:05:15 PM]
No I'm not defining any functions in my headers, only the prototypes. Should I just define the globals in the header as extern? Is that my problem?

Linking...
m_win32.obj : error LNK2005: "unsigned char fullscreen" (?fullscreen@@3EA) already defined in m_vid.obj
m_win32.obj : error LNK2005: "unsigned char active" (?active@@3EA) already defined in m_vid.obj
m_win32.obj : error LNK2005: "struct HWND__ * hWnd" (?hWnd@@3PAUHWND__@@A) already defined in m_vid.obj
m_win32.obj : error LNK2005: "struct HDC__ * hDC" (?hDC@@3PAUHDC__@@A) already defined in m_vid.obj
m_win32.obj : error LNK2005: "struct HGLRC__ * hRC" (?hRC@@3PAUHGLRC__@@A) already defined in m_vid.obj
m_win32.obj : error LNK2005: "struct HINSTANCE__ * hInstance" (?hInstance@@3PAUHINSTANCE__@@A) already defined in m_vid.obj
m_win32.obj : error LNK2005: "struct vmode_t currentmode" (?currentmode@@3Uvmode_t@@A) already defined in m_vid.obj
m_camera.obj : error LNK2005: _M3D_PI already defined in m_vid.obj
m_camera.obj : error LNK2005: _CosT already defined in m_vid.obj
m_camera.obj : error LNK2005: _SinT already defined in m_vid.obj
Debug/MillenniuM.exe : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.

Thanks

[edit]Oh yeah, math3d.h is the header for my math library that I made[/edit]

[edited by - p4n1c on September 2, 2002 9:01:20 PM]
-----For I have seen the face of evil and it will not soon be forgotten.
Are they errors conserning your globals? You should only define them once, presumably in your m_win32.cpp file. All other files that need access to these globals should declare them as externs, simply by putting the extern keyword in front of them.
For example, I asume that hWnd is a global of yours. You should define this in m_win32.cpp as HWND hWnd, and in m_vid.cpp as extern HWND hWnd. I usually put externs in the .cpp files instead of header files, for reasons unknown to me , but perhaps because I consider them a sort of "hack" so they don''t need to comply to the rules.

Just make sure you don''t define the same variable or function in more than one .cpp file, and you should be able to go on.
Thanks for the help. extern did the trick.
-----For I have seen the face of evil and it will not soon be forgotten.

This topic is closed to new replies.

Advertisement