luaplus for OGRE+CEGUI subscribeEvent() link error!

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

kuangxiang
Just popping in
Just popping in
Posts: 3
Joined: Tue Sep 07, 2010 17:10

luaplus for OGRE+CEGUI subscribeEvent() link error!

Postby kuangxiang » Tue Sep 07, 2010 17:24

hello,please help:
I use ogre+CEGUI+luaplus,I want to call subscribeEvent() in my class CGameUIScript,so When click a CEGUI button I can run a luaplus script to do something,
Ogre version is 1.7.1,CEGUI version is 0.7.1,my CGameUIScript as follow:

Code: Select all

//--------------------------------------------------------
#include <CEGUIScriptModule.h>
#include <ceguievent.h>
#include <CEGUIEventSet.h>

namespace CEGUI
{

class CGameUIScript : public ScriptModule
{

public:   
   CGameUIScript();
   virtual ~CGameUIScript();


    void executeScriptFile(const String& filename, const String& resourceGroup);

    void executeScriptFile(const String& filename,
                           const String& resourceGroup,
                           const String& error_handler);

   
    void executeScriptFile(const String& filename,
                           const String& resourceGroup,
                           const int error_handler);

    int executeScriptGlobal(const String& function_name);

   
    int executeScriptGlobal(const String& function_name,
                            const String& error_handler);

    int executeScriptGlobal(const String& function_name,
                            const int error_handler);


    bool executeScriptedEventHandler(const String& handler_name,
                                     const EventArgs& e);

   
    bool executeScriptedEventHandler(const String& handler_name,
                                     const EventArgs& e,
                                     const String& error_handler);

    bool executeScriptedEventHandler(const String& handler_name,
                                     const EventArgs& e,
                                     const int error_handler);

    void executeString(const String& str);

   
    void executeString(const String& str, const String& error_handler);

   
    void executeString(const String& str, const int error_handler);

    Event::Connection subscribeEvent(EventSet* target, const String& name,
                                     const String& subscriber_name);

   
    Event::Connection subscribeEvent(EventSet* target, const String& name,
                                     const String& subscriber_name,
                                     const String& error_handler);

   
    Event::Connection subscribeEvent(EventSet* target, const String& name,
                                     const String& subscriber_name,
                                     const int error_handler);

    Event::Connection   subscribeEvent(EventSet* target, const String& name,
                                       Event::Group group,
                                       const String& subscriber_name);

   
    Event::Connection subscribeEvent(EventSet* target, const String& name,
                                     Event::Group group,
                                     const String& subscriber_name,
                                     const String& error_handler);

    Event::Connection subscribeEvent(EventSet* target, const String& name,
                                     Event::Group group,
                                     const String& subscriber_name,
                                     const int error_handler);

    void createBindings(void);

    void destroyBindings(void);

};

}

//------------------------------------------------------------------------------
and I want to subscribe a luaplus event,the code as follow:

//-----------------------------------------------------------------------------------

Code: Select all

/*************************************************************************
   Subscribe to a scripted event handler
*************************************************************************/
Event::Connection CGameUIScript::subscribeEvent(EventSet* target,
    const String& event_name, const String& subscriber_name)
{
      if(target)
   {
      ScriptFunctor functor(subscriber_name);
      Event::Connection con = target->subscribeEvent(event_name, Event::Subscriber(functor));
      return con;      
      
   }
   throw ;

}

//------------------------------
but when I use vs2005 compile this project,one link error appear:

UIScript.obj : error LNK2019: can't solve extern symbol "public: bool __thiscall CEGUI::ScriptFunctor::operator()(class CEGUI::EventArgs const &)const " (??RScriptFunctor@CEGUI@@QBE_NABVEventArgs@1@@Z),this symbol is in "public: virtual bool __thiscall CEGUI::FunctorCopySlot<class CEGUI::ScriptFunctor>::operator()(class CEGUI::EventArgs const &)" (??R?FunctorCopySlot@VScriptFunctor@CEGUI@@@CEGUI@@UAE_NABVEventArgs@1@@Z) .....

i would appreciate any help!
Last edited by kuangxiang on Thu Sep 09, 2010 11:46, edited 1 time in total.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: luaplus for OGRE+CEGUI subscribeEvent() link error!

Postby CrazyEddie » Wed Sep 08, 2010 17:32

Please put code in [code][/code] tags. I don't want eye cancer, thanks ;)

CE.

kuangxiang
Just popping in
Just popping in
Posts: 3
Joined: Tue Sep 07, 2010 17:10

Re: luaplus for OGRE+CEGUI subscribeEvent() link error!

Postby kuangxiang » Thu Sep 09, 2010 11:47

thanks a lot!

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: luaplus for OGRE+CEGUI subscribeEvent() link error!

Postby CrazyEddie » Thu Sep 09, 2010 18:20

OK, I think the issue is because we're not exporting CEGUI::ScriptFunctor from the DLL. Can you try this patch (and rebuild CEGUI) and let us know if it fixes the issue for you:

Code: Select all

Index: cegui/include/CEGUIScriptModule.h
===================================================================
--- cegui/include/CEGUIScriptModule.h   (revision 2614)
+++ cegui/include/CEGUIScriptModule.h   (working copy)
@@ -235,7 +235,7 @@
 \brief
        Functor class used for binding named script functions to events
 */
-class ScriptFunctor
+class CEGUIEXPORT ScriptFunctor
 {
 public:
        ScriptFunctor(const String& functionName) : scriptFunctionName(functionName) {}


If this works, I'll make sure the fix goes in for the next release :)

CE.

kuangxiang
Just popping in
Just popping in
Posts: 3
Joined: Tue Sep 07, 2010 17:10

Re: luaplus for OGRE+CEGUI subscribeEvent() link error!

Postby kuangxiang » Sat Sep 11, 2010 07:47

class CEGUIEXPORT ScriptFunctor is right,now no link error again,All the thing looks good!
thanks CrazyEddie!!


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 4 guests