Archived

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

yanuart

Linking Error

Recommended Posts

I have a problem in compiling my DirectX Project, somehow it shows error message while it was in the lingking proccess the error was : Object3D.obj : error LNK2005: "unsigned char * D3DRM_XTEMPLATES" (?D3DRM_XTEMPLATES@@3PAEA) already defined in D3DApp.obj I don''t think I''ve encountered such a problem before, can somebody tell me why ?? my guess was I''ve overlapped the headers file but I''ve check that there''s no overlapping of the header files (I''ve never declare an object twice) As u can see that I''ve created another object inside my D3D wrappers, but i''ve tried before and it worked fine Please can somebody help me ?? Cause I''m very confuse right now ??

Share this post


Link to post
Share on other sites
Maybe the order of your header files is f*cked..

Some of my projects compile with VERY strange error messages, UNLESS windows.h is the first file included...

Share this post


Link to post
Share on other sites
I have had a very similar problem with my project as well.
What I found with mine was that it was complaining about variable instances being declared in the header files. I am new to C++ and don''t know the reasons behind it, but to fix the linker problem I just declared the variable as extern and instantiated the structure in the corresponding .cpp file.
This took me a long time to track down. Hope it helps!

Steele.

(If this makes no sense, I will post my example tonight after work - don''t have access to my code from here and I don''t know enough about it to remember!) :-)

Share this post


Link to post
Share on other sites
ahhh yes the extern declaration...should''ve thought of that...

  
//main.h

extern HWND g_hWnd;

//main.cpp

#include "main.h"
HWND g_hWnd = NULL;

//engine1.cpp

#include "main.h"

//now engine1.cpp has access to the global g_hWnd variable

//which is created and defined in main.cpp




hth...thanks Crowknee for the memory bump..

Share this post


Link to post
Share on other sites