Archived

This topic is now archived and is closed to further replies.

IFooBar

HUGE linker problems I have

Recommended Posts

ok i dunno what this stuff is supposed to mean but i have a d3d prog that just makes a cube spin on the screen and it gives me like 60 linker errors but the code is all fine...i have no idea what im doing wrong can anyone help? here are the errors.............brace yourselves: init.obj : error LNK2005: "struct IDirect3DVertexBuffer8 * g_vb8" (?g_vb8@@3PAUIDirect3DVertexBuffer8@@A) already defined in main.obj init.obj : error LNK2005: "struct IDirect3DDevice8 * g_d3ddevice" (?g_d3ddevice@@3PAUIDirect3DDevice8@@A) already defined in main.obj init.obj : error LNK2005: "struct IDirect3D8 * g_d3d8" (?g_d3d8@@3PAUIDirect3D8@@A) already defined in main.obj init.obj : error LNK2005: "struct HWND__ * g_mainWindow" (?g_mainWindow@@3PAUHWND__@@A) already defined in main.obj init.obj : error LNK2005: "bool g_appDone" (?g_appDone@@3_NA) already defined in main.obj init.obj : error LNK2005: "bool g_fullscreen" (?g_fullscreen@@3_NA) already defined in main.obj init.obj : error LNK2005: "class Cgame * game" (?game@@3PAVCgame@@A) already defined in main.obj init.obj : error LNK2005: "struct HINSTANCE__ * g_instance" (?g_instance@@3PAUHINSTANCE__@@A) already defined in main.obj init.obj : error LNK2005: "class Cwin win" (?win@@3VCwin@@A) already defined in main.obj init.obj : error LNK2005: "class Cdebug debug" (?debug@@3VCdebug@@A) already defined in main.obj init.obj : error LNK2005: "class Cinit * init" (?init@@3PAVCinit@@A) already defined in main.obj debug.obj : error LNK2005: "struct IDirect3DVertexBuffer8 * g_vb8" (?g_vb8@@3PAUIDirect3DVertexBuffer8@@A) already defined in main.obj debug.obj : error LNK2005: "struct IDirect3DDevice8 * g_d3ddevice" (?g_d3ddevice@@3PAUIDirect3DDevice8@@A) already defined in main.obj debug.obj : error LNK2005: "struct IDirect3D8 * g_d3d8" (?g_d3d8@@3PAUIDirect3D8@@A) already defined in main.obj debug.obj : error LNK2005: "struct HWND__ * g_mainWindow" (?g_mainWindow@@3PAUHWND__@@A) already defined in main.obj debug.obj : error LNK2005: "bool g_appDone" (?g_appDone@@3_NA) already defined in main.obj debug.obj : error LNK2005: "bool g_fullscreen" (?g_fullscreen@@3_NA) already defined in main.obj debug.obj : error LNK2005: "class Cgame * game" (?game@@3PAVCgame@@A) already defined in main.obj debug.obj : error LNK2005: "struct HINSTANCE__ * g_instance" (?g_instance@@3PAUHINSTANCE__@@A) already defined in main.obj debug.obj : error LNK2005: "class Cwin win" (?win@@3VCwin@@A) already defined in main.obj debug.obj : error LNK2005: "class Cdebug debug" (?debug@@3VCdebug@@A) already defined in main.obj debug.obj : error LNK2005: "class Cinit * init" (?init@@3PAVCinit@@A) already defined in main.obj game.obj : error LNK2005: "struct IDirect3DVertexBuffer8 * g_vb8" (?g_vb8@@3PAUIDirect3DVertexBuffer8@@A) already defined in main.obj game.obj : error LNK2005: "struct IDirect3DDevice8 * g_d3ddevice" (?g_d3ddevice@@3PAUIDirect3DDevice8@@A) already defined in main.obj game.obj : error LNK2005: "struct IDirect3D8 * g_d3d8" (?g_d3d8@@3PAUIDirect3D8@@A) already defined in main.obj game.obj : error LNK2005: "struct HWND__ * g_mainWindow" (?g_mainWindow@@3PAUHWND__@@A) already defined in main.obj game.obj : error LNK2005: "bool g_appDone" (?g_appDone@@3_NA) already defined in main.obj game.obj : error LNK2005: "bool g_fullscreen" (?g_fullscreen@@3_NA) already defined in main.obj game.obj : error LNK2005: "class Cgame * game" (?game@@3PAVCgame@@A) already defined in main.obj game.obj : error LNK2005: "struct HINSTANCE__ * g_instance" (?g_instance@@3PAUHINSTANCE__@@A) already defined in main.obj game.obj : error LNK2005: "class Cwin win" (?win@@3VCwin@@A) already defined in main.obj game.obj : error LNK2005: "class Cdebug debug" (?debug@@3VCdebug@@A) already defined in main.obj game.obj : error LNK2005: "class Cinit * init" (?init@@3PAVCinit@@A) already defined in main.obj win.obj : error LNK2005: "struct IDirect3DVertexBuffer8 * g_vb8" (?g_vb8@@3PAUIDirect3DVertexBuffer8@@A) already defined in main.obj win.obj : error LNK2005: "struct IDirect3DDevice8 * g_d3ddevice" (?g_d3ddevice@@3PAUIDirect3DDevice8@@A) already defined in main.obj win.obj : error LNK2005: "struct IDirect3D8 * g_d3d8" (?g_d3d8@@3PAUIDirect3D8@@A) already defined in main.obj win.obj : error LNK2005: "struct HWND__ * g_mainWindow" (?g_mainWindow@@3PAUHWND__@@A) already defined in main.obj win.obj : error LNK2005: "bool g_appDone" (?g_appDone@@3_NA) already defined in main.obj win.obj : error LNK2005: "bool g_fullscreen" (?g_fullscreen@@3_NA) already defined in main.obj win.obj : error LNK2005: "class Cgame * game" (?game@@3PAVCgame@@A) already defined in main.obj win.obj : error LNK2005: "struct HINSTANCE__ * g_instance" (?g_instance@@3PAUHINSTANCE__@@A) already defined in main.obj win.obj : error LNK2005: "class Cwin win" (?win@@3VCwin@@A) already defined in main.obj win.obj : error LNK2005: "class Cdebug debug" (?debug@@3VCdebug@@A) already defined in main.obj win.obj : error LNK2005: "class Cinit * init" (?init@@3PAVCinit@@A) already defined in main.obj win.obj : error LNK2001: unresolved external symbol "public: __thiscall Cdebug::Cdebug(void)" (??0Cdebug@@QAE@XZ) main.obj : error LNK2001: unresolved external symbol "public: __thiscall Cdebug::Cdebug(void)" (??0Cdebug@@QAE@XZ) init.obj : error LNK2001: unresolved external symbol "public: __thiscall Cdebug::Cdebug(void)" (??0Cdebug@@QAE@XZ) debug.obj : error LNK2001: unresolved external symbol "public: __thiscall Cdebug::Cdebug(void)" (??0Cdebug@@QAE@XZ) game.obj : error LNK2001: unresolved external symbol "public: __thiscall Cdebug::Cdebug(void)" (??0Cdebug@@QAE@XZ) win.obj : error LNK2001: unresolved external symbol "public: __thiscall Cdebug::~Cdebug(void)" (??1Cdebug@@QAE@XZ) main.obj : error LNK2001: unresolved external symbol "public: __thiscall Cdebug::~Cdebug(void)" (??1Cdebug@@QAE@XZ) init.obj : error LNK2001: unresolved external symbol "public: __thiscall Cdebug::~Cdebug(void)" (??1Cdebug@@QAE@XZ) debug.obj : error LNK2001: unresolved external symbol "public: __thiscall Cdebug::~Cdebug(void)" (??1Cdebug@@QAE@XZ) game.obj : error LNK2001: unresolved external symbol "public: __thiscall Cdebug::~Cdebug(void)" (??1Cdebug@@QAE@XZ) win.obj : error LNK2001: unresolved external symbol "public: __thiscall Cwin::Cwin(void)" (??0Cwin@@QAE@XZ) main.obj : error LNK2001: unresolved external symbol "public: __thiscall Cwin::Cwin(void)" (??0Cwin@@QAE@XZ) init.obj : error LNK2001: unresolved external symbol "public: __thiscall Cwin::Cwin(void)" (??0Cwin@@QAE@XZ) debug.obj : error LNK2001: unresolved external symbol "public: __thiscall Cwin::Cwin(void)" (??0Cwin@@QAE@XZ) game.obj : error LNK2001: unresolved external symbol "public: __thiscall Cwin::Cwin(void)" (??0Cwin@@QAE@XZ) Debug/trytry.exe : fatal error LNK1120: 3 unresolved externals Error executing link.exe. all say basically the same thing

Share this post


Link to post
Share on other sites
The first set of errors (LNK2005) looks like a nested #include problem. Have you made sure that the compiler won''t bother parsing your .H files more than once?

You do this using either a portable trick like:

#ifndef MYHEADER__
#define MYHEADER__

...headerfile

#endif

or, if you''re happy using MS'' compiler directives, you can use:

#pragma once

at the top of each of each header file. (I think that''s the syntax, but I haven''t got Visual Studio installed on this laptop.)

As for the LNK2001 errors, it''s whining about missing class constructors and destructors. If you''re sure you have defined them, it may be that the linker isn''t seeing them, possibly as a side-effect of the LNK2005 errors. Try fixing the header problem and see if these other errors go away.

Without seeing the relevant source code, I can''t say with any certainty what else could be causing the problem.




--
Sean Timarco Baggaley

Share this post


Link to post
Share on other sites