• Advertisement

Archived

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

Linker errors by the bag full

This topic is 5494 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I realise that this problem has graced these boards a number of times, but it seems it has caught me out this time. I have started a new project to begin using what I have learned to make something useful, but ye olde linker has had at me with quite a large hurty stick. I have used the directx application wizard (don't hate me for that) which worked fine, but in order to keep things centralised, I have started to remodel the app with a single global header file, which looks something like :
  
#ifndef __WIZARDIO_
#define __WIZARDIO_

#define INITGUID

#define WIN32_LEAN_AND_MEAN

#include <windows.h>
#include <windowsx.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#include <assert.h>
#include <basetsd.h>
#include <mmsystem.h>

#include <d3d8.h>
#include <d3dx8.h>
#include <rmxfguid.h>
#include <rmxftmpl.h>


// Global definitions

//#define VertexFVF (D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1)
#define VertexFVF (D3DFVF_XYZ | D3DFVF_DIFFUSE)


//typedef 

struct sVertex{
	FLOAT x, y, z;
	D3DCOLOR diffuse;
	//FLOAT u, v;

};


#include "mysprite.h"



void DebugPrint( TCHAR* strMsg, ... );

// Useful Macros (the useless ones have been cut)

#define ReleaseCOM(x) if(x) { x->Release(); x = NULL; }




#include "D3DApp.h"
#include "D3DFont.h"
#include "D3DFile.h"
#include "D3DUtil.h"
#include "DXUtil.h"
#include "D3DRes.h"
#include "resource.h"
#include "wizard.h"


#include "mysprite.h"

#endif
  
For my troubles, I get a plethora of linker errors. Here is a sample : d3dfile.obj : error LNK2005: "unsigned char * D3DRM_XTEMPLATES" (?D3DRM_XTEMPLATES@@3PAEA) already defined in d3dapp.obj d3dfile.obj : error LNK2005: _TID_D3DRMRightHanded already defined in d3dapp.obj d3dfile.obj : error LNK2005: _TID_D3DRMPropertyBag already defined in d3dapp.obj d3dfile.obj : error LNK2005: _TID_D3DRMStringProperty already defined in d3dapp.obj d3dfile.obj : error LNK2005: _TID_D3DRMExternalVisual already defined in d3dapp.obj Well, you get the idea. Anyway, some tips on how to fix this problem would be greatly appreciated. Thanks, Steele. Edit: source tags [edited by - Crow-knee on February 3, 2003 4:17:12 AM] [edited by - Crow-knee on February 3, 2003 4:18:34 AM]

Share this post


Link to post
Share on other sites
Advertisement
I would put a bet (although small) that you define something in your headers, and thus it''s defined in more than one of your object files. You must only declare stuff in your headers.


Share this post


Link to post
Share on other sites
Well, I''m not entirely sure about this one but it might help...
It''s possible that d3dapp.h already includes d3d8.h, d3d8x.h...(and so on and so forth). If it does you only need to include d3dapp.h and not the rest...
Hope this helps at least a little bit

Share this post


Link to post
Share on other sites
quote:
Original post by gargoylle_ltk
It's possible that d3dapp.h already includes d3d8.h, d3d8x.h...(and so on and so forth). If it does you only need to include d3dapp.h and not the rest...
Those headers are standard headers, right? If so, they should have inclusion guards. But, that should not cause the errors he sees anyway, as they clearly indicates that he has defined the same identifiers multiple times in the same project.




[edited by - CWizard on February 3, 2003 4:45:24 AM]

Share this post


Link to post
Share on other sites
Again, not entirely sure about this one...
By the way d3dapp.h is included I think it is generated "on the fly" by the wizard. If so, it might (MIGHT) include the other standard headers thus making re-inclusion not necesary...
(please note that I have never use the wizard so I''m basicaly just guesing here :D )

Share this post


Link to post
Share on other sites
Yep.
Even my header files have inclusion guards.
Could there be a project setting (VC++ 6.0) that I have forgotten about? I have a project almost identical, which does not get these linker errors.
The thing is, I don''t get an error about any of my definitions or types, just those defined in the standard DX8 headers. I''m using DX8.1 if that makes a difference. The errors are pretty much all of the _TID_*, _IID_*, _CLSID_CDirectXFile and D3DRM_XTEMPLATES.
I have been over the header files directly included into my project multiple times, and there are no instanciations of variables that I can see (externs used appropriately). The header file inclusions have all been taken out.

Most troublesome.
Thanks for the quick replies.
Steele.

Share this post


Link to post
Share on other sites
I would take a closer look at "mysprite.h" (which you include twice in that file).

Share this post


Link to post
Share on other sites
No idea really, but the errors clearly indicates that something that is defined in d3dfile.cpp (d3dfile.obj) has already been defined in in d3dapp.cpp (d3dapp.obj). I have no idea what sort of crap VC is generating for you, but it shouldn''t define anything in a header.

If you want, send the project to my email address (in profile), and I''ll check and see if I can catch it.


Share this post


Link to post
Share on other sites
Oh yes. I did include it twice. A cut and paste mistake.
Here is the mysprite header anyway. The errors still occur without it though. 431 errors down from 517.


  
#ifndef __MYSPRITE_
#define __MYSPRITE_

class c_Sprite {
public:
bool Init(IDirect3DDevice8 *d3dDevice, sVertex sVerts[], long VertNum);
MoveTo(float x, float y, float z);
MoveBy(float x, float y, float z);
RotateX(float rads);
RotateY(float rads);
RotateZ(float rads);
bool Draw(IDirect3DDevice8 *d3dDevice);
Update();
~c_Sprite();
protected:
float xPos, yPos, zPos;
float xRot, yRot, zRot;
float xScale, yScale, zScale;
D3DXMATRIX matWorld;
IDirect3DVertexBuffer8 *VB;

D3DMATERIAL8 mtrl;

};

#endif

Still puzzles me...

Share this post


Link to post
Share on other sites
quote:
Original post by Crow-knee
Still puzzles me...
Me as well

What source files are in the project, and do they include anything else besides you''re global header?

Has this been a problem since you started the project? If not so, try to remember what you added to cause these errors.


Share this post


Link to post
Share on other sites
Got your mail, I''ll look at it soon enough.

I tried to build a DX project my self, then putted in all headers of all generated files in one, and got a familiar message:
"d3dapp.obj : error LNK2005: "unsigned char * D3DRM_XTEMPLATES" (?D3DRM_XTEMPLATES@@3PAEA) already defined in d3dfile.obj"

After little investigation, I find that D3DRM_XTEMPLATES is defined (not only declared) in rmxftmpl.h. So, this one must only be included in one of you source files. VC++ choose the d3dfile.cpp, which might be appropriate.

I''ll look at the other errors now.


Share this post


Link to post
Share on other sites
ok, I didn''t get any of the _TID_ errors when compiling your project. After I moved the #include <rmxftmpl.h> from global.h and put it in d3dfile.cpp, the project compiled and linked fine.

Hope that solves your problem.


Share this post


Link to post
Share on other sites
Shazbot!!
Nope. I still get the errors.
This may require a re-install. I am running out of ideas.
Thanks all for your help.
I''ll keep watching this thread incase anyone else has a clue, meanwhile, I shall do a re-install.
Steele.

Share this post


Link to post
Share on other sites
Finally!! Some closure.
A new project, a fresh start and everything comes up just peachy.
Thanks everyone for your help.
Good ol'' VC++.
Now to delete that troublesome project... now where''s me magnet???

Share this post


Link to post
Share on other sites
Good to hear. I tracked down those _TID_D3DRMxxx identifiers to the rmxfguid.h file, and was about to suggest you to only include that one in a single source file, but saw that you solved it. Sometimes a fresh start solves everything (weird, isn''t it?)


Share this post


Link to post
Share on other sites

  • Advertisement