开发者

OOLua link errors

开发者 https://www.devze.com 2022-12-15 20:03 出处:网络
Code #include <OOLua/oolua.h> class foo { public: int bar(); }; OOLUA_CLASS_NO_BASES(foo)//cl开发者_高级运维ass has no bases

Code

#include <OOLua/oolua.h>

class foo
{
public:
  int bar();
};

OOLUA_CLASS_NO_BASES(foo)//cl开发者_高级运维ass has no bases
    OOLUA_NO_TYPEDEFS
    OOLUA_MEM_FUNC_0(int,bar)
OOLUA_CLASS_END

void test()
{
    OOLUA::Script s;
    s.register_class<foo>();
}

Compiler output

1>main.obj : error LNK2001: unresolved external symbol "public: static struct OOLUA::Proxy_class<class foo>::Reg_type_const * OOLUA::Proxy_class<class foo>::class_methods_const" (?class_methods_const@?$Proxy_class@Vfoo@@@OOLUA@@2PAUReg_type_const@12@A)
1>main.obj : error LNK2001: unresolved external symbol "public: static struct OOLUA::Proxy_class<class foo>::Reg_type * OOLUA::Proxy_class<class foo>::class_methods" (?class_methods@?$Proxy_class@Vfoo@@@OOLUA@@2PAUReg_type@12@A)
1>main.obj : error LNK2001: unresolved external symbol "public: static char const * const OOLUA::Proxy_class<class foo>::class_name" (?class_name@?$Proxy_class@Vfoo@@@OOLUA@@2QBDB)
1>main.obj : error LNK2001: unresolved external symbol "public: static char const * const OOLUA::Proxy_class<class foo>::class_name_const" (?class_name_const@?$Proxy_class@Vfoo@@@OOLUA@@2QBDB)
1>main.obj : error LNK2001: unresolved external symbol "public: static int const OOLUA::Proxy_class<class foo>::name_size" (?name_size@?$Proxy_class@Vfoo@@@OOLUA@@2HB)

Using

Visual Studio 2008

OOLua 1.2.1

(OOLua .lib has been built and linked to)
(OOLua solution via premake 3 with test.unit and profile projects removed)
(OOLua obtained via SVN -> trunk | Jan 3rd)

Links

http://code.google.com/p/oolua/

OOLua compile errors

Question

How can it be fixed?

Solution

class foo
{
public:
  int bar()
  {
      return 0;
  }
};

OOLUA_CLASS_NO_BASES(foo)//class has no bases
    OOLUA_NO_TYPEDEFS
    OOLUA_MEM_FUNC_0(int,bar)
OOLUA_CLASS_END

EXPORT_OOLUA_FUNCTIONS_1_NON_CONST(foo /*name of class*/
                                  ,bar)/*function being exposed*/
EXPORT_OOLUA_FUNCTIONS_0_CONST(foo)

void test()
{
    OOLUA::Script s;
    s.register_class<foo>();
}


http://code.google.com/p/oolua/wiki/CheatSheet#Has_a_member_function_which_takes_no_parameters

Then in a source file expose the class telling the framework that the instance has a function of interest yet no constant member functions, also providing the name it will be identified by in Lua code(foo).

EXPORT_OOLUA_FUNCTIONS_1_NON_CONST(foo /*name of class*/
                                  ,bar)/*function being exposed*/
EXPORT_OOLUA_FUNCTIONS_0_CONST(foo)
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号