So I have this main.cpp and another header and cpp file called system.h and system.cpp
I declared the LPDIRECT3D9 and LPDIRECT3DDEVICE9 type variables like:
extern LPDIRECT3D9 g_pD3D;
extern LPDIRECT3DDEVICE9 g_pd3dDevice;
on my system.h and initialized them inside my system.cpp file
at my main.cpp, I included the system.h file like :
#include "system.h"
when I tried to compile it, it said that something along the lines of:
error LNK2005: "struct IDirect3D9 * g_pD3D" (?g_pD3D@@3PAUIDirect3D9@@A) already defined in main.obj
and the same error for the second variable.
I haven't defined or declared the two variables on the main.cpp, I haven't even called the two variables at all.
I temporarily solved the problem by using extern on the two variables on system.h
But I have a feeling that this might not be a 100% solution.
I was wondering what was causing the problem and how can I fix it..
Thank you in advance.
Question regarding LNK2005
Re: Question regarding LNK2005
Dunno. Maybe the header is viewed multiple times. Do you have a header guard in it?
A header guard will make sure the file is only read once.
A header guard will make sure the file is only read once.
ʕ •ᴥ•ʔ
Re: Question regarding LNK2005
Can't say without seeing your code. It's some sort of redefinition.
Chili