Liker error while trying to extend and recompile irrlicht

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.
newbie8787
Posts: 105
Joined: Thu Jan 10, 2008 6:26 pm

Liker error while trying to extend and recompile irrlicht

Post by newbie8787 »

I am trying to create a custom IGUIElement in irrlicht, for that I have included the sources from irrlicht and extended the CIGUIStatictext class. Now whenever I try to compile my project , I get a host of linker errors , I must admit to ignorance of the compilation process and am not really able to figure out why this is happening. I'm including the source for both my header and cpp class as pastebin links :

Header : http://pastebin.com/5pCnHLG0
Cpp : http://pastebin.com/WtW36Qek

sample of the linker errors :

1>graphNode.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall irr::gui::CGUIStaticText::~CGUIStaticText(void)" (??1CGUIStaticText@gui@irr@@UAE@XZ) referenced in function __unwindfunclet$??0graphNode@gui@irr@@QAE@PAVIGUIEnvironment@12@PAVIGUIElement@12@HV?$rect@H@core@2@PB_W@Z$0 1>graphNode.obj : error LNK2019: unresolved external symbol "public: __thiscall irr::gui::CGUIStaticText::CGUIStaticText(wchar_t const *,bool,class irr::gui::IGUIEnvironment *,class irr::gui::IGUIElement *,int,class irr::core::rect const &,bool)" (??0CGUIStaticText@gui@irr@@QAE@PB_W_NPAVIGUIEnvironment@12@PAVIGUIElement@12@HABV?$rect@H@core@2@1@Z) referenced in function "public: __thiscall irr::gui::graphNode::graphNode(class irr::gui::IGUIEnvironment *,class irr::gui::IGUIElement *,int,class irr::core::rect,wchar_t const *)" (??0graphNode@gui@irr@@QAE@PAVIGUIEnvironment@12@PAVIGUIElement@12@HV?$rect@H@core@2@PB_W@Z) 1>graphNode.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall irr::gui::graphNode::OnEvent(struct irr::SEvent const &)" (?OnEvent@graphNode@gui@irr@@UAE_NABUSEvent@3@@Z) 1>graphNode.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall irr::gui::CGUIStaticText::updateAbsolutePosition(void)" (?updateAbsolutePosition@CGUIStaticText@gui@irr@@UAEXXZ) 1>graphNode.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall irr::gui::CGUIStaticText::draw(void)" (?draw@CGUIStaticText@gui@irr@@UAEXXZ) 1>graphNode.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall irr::gui::CGUIStaticText::setText(wchar_t const *)" (?setText@CGUIStaticText@gui@irr@@UAEXPB_W@Z)
REDDemon
Developer
Posts: 1044
Joined: Tue Aug 31, 2010 8:06 pm
Location: Genova (Italy)

Re: Liker error while trying to extend and recompile irrlich

Post by REDDemon »

you don't have implemented OnEvent wich is pure virtual. If you want the old OnEvent of CGUIStaticText you ave to remove "OnEvent" from your header (there can still be more errors. at a first look is what I saw). Else you are supposed to provide your own version of OnEvent. It is better to look at few web tutorials about Polymorphism. they can help you a lot (check out also Thinking C++ wich is a great book).
Junior Irrlicht Developer.
Real value in social networks is not about "increasing" number of followers, but about getting in touch with Amazing people.
- by Me
newbie8787
Posts: 105
Joined: Thu Jan 10, 2008 6:26 pm

Re: Liker error while trying to extend and recompile irrlich

Post by newbie8787 »

REDDemon wrote:you don't have implemented OnEvent wich is pure virtual. If you want the old OnEvent of CGUIStaticText you ave to remove "OnEvent" from your header (there can still be more errors. at a first look is what I saw). Else you are supposed to provide your own version of OnEvent. It is better to look at few web tutorials about Polymorphism. they can help you a lot (check out also Thinking C++ wich is a great book).
Yes , I realize that I havent , as of yet implemented all pure virtual methods, but the errors that I am getting are about Linking , If those could be resolved I can move on to resolve the more conventional problems with my program.
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Re: Liker error while trying to extend and recompile irrlich

Post by serengeor »

REDDemon wrote:you don't have implemented OnEvent wich is pure virtual
Is it, last time I checked IGUIElement had it implemented.
http://irrlicht.sourceforge.net/docu/_i ... tml#l00514
Working on game: Marrbles (Currently stopped).
newbie8787
Posts: 105
Joined: Thu Jan 10, 2008 6:26 pm

Re: Liker error while trying to extend and recompile irrlich

Post by newbie8787 »

If you're curious about the library being set up properly , the whole system was working fine , linking and all (along with displaying some static text on screen) until i decided to create my own version.
REDDemon
Developer
Posts: 1044
Joined: Tue Aug 31, 2010 8:06 pm
Location: Genova (Italy)

Re: Liker error while trying to extend and recompile irrlich

Post by REDDemon »

what I mean is that he write the OnEvent method. no matters if it was implemented previously. Since when he write again the prototype in the header the linker expect it to be implemented again while he doesn't implemented it ;-). So or he remove the prototype from the header or he just implement that again in the source file. If I'm correct there will not be compiling errors in this case but only linking errors.
Junior Irrlicht Developer.
Real value in social networks is not about "increasing" number of followers, but about getting in touch with Amazing people.
- by Me
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Re: Liker error while trying to extend and recompile irrlich

Post by serengeor »

newbie8787 wrote:If you're curious about the library being set up properly , the whole system was working fine , linking and all (along with displaying some static text on screen) until i decided to create my own version.
You should probably inherit only the interface classes instead of their implementations. At least I've heard that it's better to just copy over the implementations from irrlicht source to your project and use those copies.

You could also try adding the CGUIStaticText file to your project. don't really know if that will help anything.
what I mean is that he write the OnEvent method. no matters if it was implemented previously. Since when he write again the prototype in the header the linker expect it to be implemented again while he doesn't implemented it . So or he remove the prototype from the header or he just implement that again in the source file. If I'm correct there will not be compiling errors in this case but only linking errors.
Yeah, you're probably right about this.
Last edited by serengeor on Fri Mar 16, 2012 5:52 pm, edited 1 time in total.
Working on game: Marrbles (Currently stopped).
newbie8787
Posts: 105
Joined: Thu Jan 10, 2008 6:26 pm

Re: Liker error while trying to extend and recompile irrlich

Post by newbie8787 »

REDDemon wrote:what I mean is that he write the OnEvent method. no matters if it was implemented previously. Since when he write again the prototype in the header the linker expect it to be implemented again while he doesn't implemented it ;-). So or he remove the prototype from the header or he just implement that again in the source file. If I'm correct there will not be compiling errors in this case but only linking errors.
Did that :) no avail ! In any case , as you can see from the sample of the linker errors i've given (there are 22) there are problems in linking almost all methods of the CGUIStaticText class
newbie8787
Posts: 105
Joined: Thu Jan 10, 2008 6:26 pm

Re: Liker error while trying to extend and recompile irrlich

Post by newbie8787 »

serengeor wrote: You should probably inherit only the interface classes instead of their implementations. At least I've heard that it's better to just copy over the implementations from irrlicht source to your project and use those copies.
The problem with that approach is that I will have to implement *all* of the methods as indicated in the interface, I just need to override the onevent method , thats about the extent of my modifications.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Liker error while trying to extend and recompile irrlich

Post by CuteAlien »

Pastebin is dead, but in short like serengeor said - you can only inherit from the interfaces in your applications. If you want a near identical class then copy it over, rename it(!) and add your changes then.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
newbie8787
Posts: 105
Joined: Thu Jan 10, 2008 6:26 pm

Re: Liker error while trying to extend and recompile irrlich

Post by newbie8787 »

But what about all the classes that the implementation depends on ?

this : http://irrlicht.sourceforge.net/forum/v ... =9&t=45795 was my inspiration for doing this
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Liker error while trying to extend and recompile irrlich

Post by CuteAlien »

You have to pass all classes you need to your class (as pointers). And yeah - your inspiration is doing it also wrong - or maybe he modified the engine itself. Might even work when it's static linked (not certain, but would make sense that it works then - still bad style).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
newbie8787
Posts: 105
Joined: Thu Jan 10, 2008 6:26 pm

Re: Liker error while trying to extend and recompile irrlich

Post by newbie8787 »

CuteAlien wrote:You have to pass all classes you need to your class (as pointers). And yeah - your inspiration is doing it also wrong - or maybe he modified the engine itself. Might even work when it's static linked (not certain, but would make sense that it works then - still bad style).
So there is no cheap and quick way to just modify the OnEvent method of the Static text element and be done with it ? I shall have to copy all implementation details from the irrlicht source and only then can I create a custom response to events on the static text elements that I add to the gui. (is there any other , not so tedious and less time consuming way to do this ? )
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Liker error while trying to extend and recompile irrlich

Post by CuteAlien »

Depends on what you really want to do. You can catch events for that element in your eventreceiver if that is what you need. There is no simply way to derive from an element, but then again copying the code and renaming the class would take me around 1 minute (+ maybe some time to get it compiling if it depends on other internal classes, that depends). So not really that big of a problem.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
newbie8787
Posts: 105
Joined: Thu Jan 10, 2008 6:26 pm

Re: Liker error while trying to extend and recompile irrlich

Post by newbie8787 »

CuteAlien wrote:Depends on what you really want to do. You can catch events for that element in your eventreceiver if that is what you need. There is no simply way to derive from an element, but then again copying the code and renaming the class would take me around 1 minute (+ maybe some time to get it compiling if it depends on other internal classes, that depends). So not really that big of a problem.
I'm trying to make a static text element that can be dragged around using the mouse and responds to one button press and the Static text element doesnt escalate any events to the event receiver, so I was trying to extend the definition to make a new onEvent method that propagates some events up the food chain and handle others internally.
Post Reply