#ifndef PLAYER
#define PLAYER
//code goes here
#endif
but I still get these dumb errors!
Stupid link errors!!!
I keep getting these stupid errors every time I compile:
player.obj : error LNK2005: "struct sTile (* map)[5]" (?map@@3PAY04UsTile@@A) already defined in class_func.obj
functions.obj : error LNK2005: "struct sTile (* map)[5]" (?map@@3PAY04UsTile@@A) already defined in class_func.obj
game.obj : error LNK2005: "struct sTile (* map)[5]" (?map@@3PAY04UsTile@@A) already defined in class_func.obj
Game___Win32_Debug/Game.exe : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.
I do multiple includes in class_func.cpp, player.cpp, and etc., and I made sure to use
Half the people you know are below average.Trogdor the Burninator
You are defining ''map'' in the header. Every source-file/module that includes this header will therefore get it''s own definition of map, and these multiple definitions will clash at link-time. The solution is to declare ''map'' extern in the header, and define it in exactly one source-file.
I have found that I get this error if I do certain defines before includes like:
#define INITGUID
#define WIN32_LEAN_AND_MEAN
#include
#include
INSTEAD OF
#include
#include
#define INITGUID
#define WIN32_LEAN_AND_MEAN
once again, I''m not an expert so I am just saying ONE thing that has caused these kind of errors for me.
#define INITGUID
#define WIN32_LEAN_AND_MEAN
#include
#include
INSTEAD OF
#include
#include
#define INITGUID
#define WIN32_LEAN_AND_MEAN
once again, I''m not an expert so I am just saying ONE thing that has caused these kind of errors for me.
ahhh okay thanks
Half the people you know are below average.Trogdor the Burninator
quote: Original post by CruxMihiAncora
I have found that I get this error if I do certain defines before includes [remove examples]
Those defines alter the behavior of the includes, so if you''re getting errors by placing them before the headers, you''re doing something wrong.
#define INITGUID, for example, should come before virtually all includes; #define WIN32_LEAN_AND_MEAN causes the inclusion of windows.h to exclude rarely used stuff - declaring it after the include is redundant.
I wanna work for Microsoft!
I hate to post this whole code segment, but any idea what I am doing wrong here? When I put the defines before the includes I get the same type of errors that Kaezin is getting. However, if I put the defines after the includes, it compiles just fine:
Yikes!!! This really expands the tabs. Sorry about the code being so wide.
Edited by - CruxMihiAncora on November 8, 2001 2:15:10 AM
Edited by - CruxMihiAncora on November 8, 2001 2:16:21 AM
Edited by - CruxMihiAncora on November 8, 2001 2:17:23 AM
#ifndef __ENGINE_H__#define __ENGINE_H__// standard includes#include <d3d8.h>#include <d3dx8.h>#include <stdio.h>// standard defines#define INITGUID#define WIN32_LEAN_AND_MEANclass CEngine { public: // ******* VARIABLES ******* // // window handles HINSTANCE m_hInstance; HWND m_hWnd; // ******* FUNCTIONS ******* // int iInit3D( void ); void vRenderScene( void ); // Constructor and Destructor CEngine( ); ~CEngine( ); private: // ******* VARIABLES ******* // // direct3d globals LPDIRECT3D8 m_pD3D; LPDIRECT3DDEVICE8 m_pD3DDevice; D3DXMATRIX m_matProj; // projection data D3DXMATRIX m_matCameraView; // camera data D3DXVECTOR3 m_vecCameraSource; D3DXVECTOR3 m_vecCameraTarget; LPDIRECT3DVERTEXBUFFER8 m_lpVertexBuffer; // definition for our vertex shader #define D3DFVF_MYVERTEX (D3DFVF_XYZ | D3DFVF_TEX1) // vertex structure typedef struct MYVERTEX { float x; float y; float z; float u; float v; } MYVERTEX, *LPMYVERTEX; // global vertices MYVERTEX m_Vertices[4]; // ******* FUNCTIONS ******* // void vSetupView( void );};#endif
Yikes!!! This really expands the tabs. Sorry about the code being so wide.
Edited by - CruxMihiAncora on November 8, 2001 2:15:10 AM
Edited by - CruxMihiAncora on November 8, 2001 2:16:21 AM
Edited by - CruxMihiAncora on November 8, 2001 2:17:23 AM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement