#include <OOLua/oolua.h>

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

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

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


编译器输出

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)


使用

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)


链接

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

OOLua compile errors



如何解决?



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


  然后在源文件中公开该类
  告诉框架
  实例具有感兴趣的功能
  还没有恒定的成员函数
  提供名称
  在Lua代码(foo)中标识。


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

关于c++ - OOLua链接错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/2014746/

10-10 21:38