Jump to content
  • Advertisement
Sign in to follow this  
wforl

linker errors

This topic is 3827 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 seem to be getting linkers errors with the helper header file i have, which i use as an include in all my .cpps, as it contains handy functions that i use below is the code (.h and .cpp) and the errors, can anyone inform me of my problem? As you can see, all the files that i included the header file with, brings up an error
#pragma once

#if defined(DEBUG) | defined(_DEBUG)
#ifndef D3D_DEBUG_INFO
#define D3D_DEBUG_INFO
#endif
#endif

//directxx
#include <d3d9.h>
#include <d3dx9.h>
#include <dxerr9.h>

//3rd party
#include <fmod.hpp>

//common
#include <stdio.h>
#include <conio.h>
#include <string>
#include <iostream>
#include <sstream>
#include <vector>
#include <list>
#include <crtdbg.h>
#include <list>
#include <tchar.h>
#include <math.h>

//////////////////////////////////////////////////////
//defines
//////////////////////////////////////////////////////

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

//////////////////////////////////////////////////////
//Helper Variables
//////////////////////////////////////////////////////

const D3DXCOLOR WHITE(1.0f, 1.0f, 1.0f, 1.0f);

const float INFINITY = FLT_MAX;
const float EPSILON  = 0.001f;

//////////////////////////////////////////////////////
//Structures
//////////////////////////////////////////////////////

D3DMATERIAL9 BasicWhiteMaterial;
	//BasicWhiteMaterial.Ambient = WHITE;
	//BasicWhiteMaterial.Diffuse = WHITE;
	//BasicWhiteMaterial.Emissive = WHITE;
	//BasicWhiteMaterial.Power = 1.0f;
	//BasicWhiteMaterial.Specular = WHITE;

struct DirLight
{
	D3DXCOLOR ambient;
	D3DXCOLOR diffuse;
	D3DXCOLOR spec;
	D3DXVECTOR3 dirW;
};

struct mouseStats
{
	bool leftMouseButton;
	bool middleMouseButton;
	bool rightMouseButton;
	bool left_dbl;
	bool right_dbl;
	bool middle_dbl;
};

struct GameStatisticsStructure
{
	int MouseTimesLeftButtonClicked;
	int MouseTimesRightButtonClicked;
	int MouseTimesMiddleButtonClicked;

	int MouseTimesLeftButtonDoubleClicked;
	int MouseTimesRightButtonDoubleClicked;
	int MouseTimesMiddleButtonDoubleClicked;

	int TriangleCountOfMeshObjectsLoaded;
	int VerticeCountOfMeshObjectsLoaded;

	int TriangleCountOfMeshObjectsRendered;
	int VerticeCountOfMeshObjectsRendered;

};

struct GameOptionsStructure
{
	GameStatisticsStructure GameStatistics;
	bool BackgroundMusic;
	bool DisplayKeyboardActivity;
	bool DisplayMouseActivity;
	bool DisplayScriptMode;
	bool Paused;
};

//////////////////////////////////////////////////////
//Functions
//////////////////////////////////////////////////////

float dToR(float num);
float rToD(float num);

void Build2dPlane(IDirect3DDevice9 * Dx9Device, IDirect3DVertexBuffer9 ** VB, IDirect3DIndexBuffer9 ** IB);

void Build3dLine(IDirect3DDevice9 * Dx9Device, IDirect3DVertexBuffer9 ** VB, IDirect3DIndexBuffer9 ** IB);

float distanceBetweenPoints(D3DXVECTOR3 p1, D3DXVECTOR3 p2);



#include "globalSettings.h"
#include "Vertex.h"

float dToR(float num)
{
	float radian = (float)57.2957795;
	return num/radian;
};


float rToD(float num)
{
	return num * (float)57.2957795;
};

void Build2dPlane(IDirect3DDevice9 * Dx9Device, IDirect3DVertexBuffer9 ** VB, IDirect3DIndexBuffer9 ** IB)
{
	// Create the vertex buffer.
	Dx9Device->CreateVertexBuffer(4 * sizeof(VertexPNT), D3DUSAGE_WRITEONLY,
		0, D3DPOOL_MANAGED,	*(&VB), 0);

	// Write box vertices to the vertex buffer.
	VertexPNT* v = 0;
	(*VB)->Lock(0, 0, (void**)&v, 0);

	// Fill in the front face vertex data.
	v[0] = VertexPNT(-1.0f, -1.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 1.0f);
	v[1] = VertexPNT(-1.0f,  1.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f);
	v[2] = VertexPNT( 1.0f,  1.0f, -1.0f, 0.0f, 0.0f, -1.0f, 1.0f, 0.0f);
	v[3] = VertexPNT( 1.0f, -1.0f, -1.0f, 0.0f, 0.0f, -1.0f, 1.0f, 1.0f);

	(*VB)->Unlock();

	// Create the vertex buffer.
	Dx9Device->CreateIndexBuffer(6 * sizeof(WORD),	D3DUSAGE_WRITEONLY,
		D3DFMT_INDEX16,	D3DPOOL_MANAGED, *(&IB), 0);

	// Write box indices to the index buffer.
	WORD* i = 0;
	(*IB)->Lock(0, 0, (void**)&i, 0);

	// Fill in the front face index data
	i[0] = 0; i[1] = 1; i[2] = 2;
	i[3] = 0; i[4] = 2; i[5] = 3;

	(*IB)->Unlock();
};

float distanceBetweenPoints(D3DXVECTOR3 p1, D3DXVECTOR3 p2)
{
	float xd = p1.x - p2.x;
	float yd = p1.y - p2.y;
	float zd = p1.z - p2.z;
	return sqrt (xd*xd + yd*yd + zd*zd);
};

void Build3dLine(IDirect3DDevice9 * Dx9Device, IDirect3DVertexBuffer9 ** VB, IDirect3DIndexBuffer9 ** IB)
{
	// Create the vertex buffer.
	Dx9Device->CreateVertexBuffer(2 * sizeof(VertexCol), D3DUSAGE_WRITEONLY,
		0, D3DPOOL_MANAGED,	*(&VB), 0);

	// Write box vertices to the vertex buffer.
	VertexCol* v = 0;
	(*VB)->Lock(0, 0, (void**)&v, 0);

	// Fill in the front face vertex data.
	v[0] = VertexCol(0.0f, 0.0f, 5.0f, D3DCOLOR_RGBA(0,0,0,1));
	v[1] = VertexCol(0.0f, 40.0f, 5.0f,D3DCOLOR_RGBA(255,0,0,1));
	
	(*VB)->Unlock();
};


Error	11	error LNK2005: "struct _D3DMATERIAL9 BasicWhiteMaterial" (?BasicWhiteMaterial@@3U_D3DMATERIAL9@@A) already defined in DX_Game.obj	globalSettings.obj
Error	12	error LNK2005: "struct _D3DMATERIAL9 BasicWhiteMaterial" (?BasicWhiteMaterial@@3U_D3DMATERIAL9@@A) already defined in DX_Game.obj	main.obj
Error	13	error LNK2005: "struct _D3DMATERIAL9 BasicWhiteMaterial" (?BasicWhiteMaterial@@3U_D3DMATERIAL9@@A) already defined in DX_Game.obj	Vertex.obj
Error	14	error LNK2005: "struct _D3DMATERIAL9 BasicWhiteMaterial" (?BasicWhiteMaterial@@3U_D3DMATERIAL9@@A) already defined in DX_Game.obj	winApp.obj
Error	15	error LNK2005: "struct _D3DMATERIAL9 BasicWhiteMaterial" (?BasicWhiteMaterial@@3U_D3DMATERIAL9@@A) already defined in DX_Game.obj	TextureLoader.obj
Error	16	error LNK2005: "struct _D3DMATERIAL9 BasicWhiteMaterial" (?BasicWhiteMaterial@@3U_D3DMATERIAL9@@A) already defined in DX_Game.obj	MeshLoader.obj
Error	17	error LNK2005: "struct _D3DMATERIAL9 BasicWhiteMaterial" (?BasicWhiteMaterial@@3U_D3DMATERIAL9@@A) already defined in DX_Game.obj	static_mesh.obj
Error	18	error LNK2005: "struct _D3DMATERIAL9 BasicWhiteMaterial" (?BasicWhiteMaterial@@3U_D3DMATERIAL9@@A) already defined in DX_Game.obj	effect.obj
Error	19	error LNK2005: "struct _D3DMATERIAL9 BasicWhiteMaterial" (?BasicWhiteMaterial@@3U_D3DMATERIAL9@@A) already defined in DX_Game.obj	GfxStats.obj
Error	20	error LNK2005: "struct _D3DMATERIAL9 BasicWhiteMaterial" (?BasicWhiteMaterial@@3U_D3DMATERIAL9@@A) already defined in DX_Game.obj	map.obj
Error	21	error LNK2005: "struct _D3DMATERIAL9 BasicWhiteMaterial" (?BasicWhiteMaterial@@3U_D3DMATERIAL9@@A) already defined in DX_Game.obj	UI.obj
Error	22	error LNK2005: "struct _D3DMATERIAL9 BasicWhiteMaterial" (?BasicWhiteMaterial@@3U_D3DMATERIAL9@@A) already defined in DX_Game.obj	UI_Item.obj
Error	23	error LNK2005: "struct _D3DMATERIAL9 BasicWhiteMaterial" (?BasicWhiteMaterial@@3U_D3DMATERIAL9@@A) already defined in DX_Game.obj	projectile.obj
Error	24	error LNK2005: "struct _D3DMATERIAL9 BasicWhiteMaterial" (?BasicWhiteMaterial@@3U_D3DMATERIAL9@@A) already defined in DX_Game.obj	weapon.obj
Error	25	error LNK2005: "struct _D3DMATERIAL9 BasicWhiteMaterial" (?BasicWhiteMaterial@@3U_D3DMATERIAL9@@A) already defined in DX_Game.obj	actor.obj
Error	26	fatal error LNK1169: one or more multiply defined symbols found	D:\Programming\My Game\Debug\FPS shooter.exe


Share this post


Link to post
Share on other sites
Advertisement
hmm, i thought that, but the fact that the following were working confused me

const D3DXCOLOR WHITE(1.0f, 1.0f, 1.0f, 1.0f);

const float INFINITY = FLT_MAX;
const float EPSILON = 0.001f;

Share this post


Link to post
Share on other sites
Because they're constant, the compiler can optimise them away. Your BasicWhiteMaterial isn't constant, so the compiler probably can't get rid of it.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!