linker error

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
koso
Posts: 27
Joined: Thu May 21, 2009 11:10 am

linker error

Post by koso »

Hi

i am trying to make my own small library, to put together graphics irrklsng and stuff. but when i am trying to compile i get this

Code: Select all

1>TGlobals.obj : error LNK2005: "void __cdecl rotateNode(class irr::scene::ISceneNode *,class irr::core::vector3d<float>)" (?rotateNode@@YAXPAVISceneNode@scene@irr@@V?$vector3d@M@core@3@@Z) already defined in techEngine.obj
1>TGlobals.obj : error LNK2005: "void __cdecl translateNode(class irr::scene::ISceneNode *,class irr::core::vector3d<float>)" (?translateNode@@YAXPAVISceneNode@scene@irr@@V?$vector3d@M@core@3@@Z) already defined in techEngine.obj
1>TRender.obj : error LNK2005: "void __cdecl rotateNode(class irr::scene::ISceneNode *,class irr::core::vector3d<float>)" (?rotateNode@@YAXPAVISceneNode@scene@irr@@V?$vector3d@M@core@3@@Z) already defined in techEngine.obj
1>TRender.obj : error LNK2005: "void __cdecl translateNode(class irr::scene::ISceneNode *,class irr::core::vector3d<float>)" (?translateNode@@YAXPAVISceneNode@scene@irr@@V?$vector3d@M@core@3@@Z) already defined in techEngine.obj
can someone explain me what is going on? i want to understand it for future.

thx
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Post by Radikalizm »

EDIT: Nevermind ^^
Last edited by Radikalizm on Tue Jan 18, 2011 7:45 pm, edited 1 time in total.
Alpha Omega
Posts: 288
Joined: Wed Oct 29, 2008 12:07 pm

Post by Alpha Omega »

It say already defined

(?translateNode@@YAXPAVISceneNode@scene@irr@@V?$vector3d@M@core@3@@Z) already defined in techEngine.obj
Are you perhaps trying to compile and using?

#include <file.cpp> because your not supposed to do that.
Iyad
Posts: 140
Joined: Sat Mar 07, 2009 1:18 am
Location: Montreal, Canada

Post by Iyad »

Maybe its occuring due to circular dependency, be sure that your files does not include themselfs more than once, use include guards or rework on your code. Sometimes, if 2 classes or more are interdependant, you can try to use a forward declaration, then redefine your declaration in another file.
#include <Iyad.h>
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Post by Radikalizm »

Iyad wrote:Maybe its occuring due to circular dependency, be sure that your files does not include themselfs more than once, use include guards or rework on your code
This could very well be the problem
You should make it a standard practice to immediately add this to a newly created header file:

Code: Select all

#ifndef    __FILE_NAME_H__
#define    __FILE_NAME_H__

// You can name the define anything you want, as long as it remains unique throughout your program


/*
CODE GOES HERE
*/

#endif    // __FILE_NAME_H__

Anthony
Posts: 121
Joined: Sun Jan 09, 2011 12:03 pm

Post by Anthony »

second that of Radkalizm

But it only counts for header files.

To keep them unique, just use the filename of the header, i.e.:

Code: Select all

// header file: header.h
#ifndef _HEADER_H_
etc.
as filenames are unique too (unless you name them into different directories the same, wich you shouldn't ;) )
No :shock: I am no noob, just checking if your not one too :roll:

Thanks to Niko and all others that made Irrlicht possible.
Post Reply