OOLua 链接错误 [英] OOLua link errors

查看:22
本文介绍了OOLua 链接错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

代码

#include 类 foo{民众:内部酒吧();};OOLUA_CLASS_NO_BASES(foo)//类没有基OOLUA_NO_TYPEDEFSOOLUA_MEM_FUNC_0(int,bar)OOLUA_CLASS_END无效测试(){OOLUA::Script s;s.register_class();}

编译器输出

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: 未解析的外部符号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: 未解析的外部符号 "public: static char const * const OOLUA::Proxy_class<class foo>::class_name" (?class_name@?$Proxy_class@Vfoo@@@OOLUA@@2QBDB)1>main.obj : error LNK2001: 未解析的外部符号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: 未解析的外部符号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 已构建并链接到)(通过 premake 3 的 OOLua 解决方案,删除了 test.unit 和 profile 项目)(通过 SVN 获得的 OOLua -> 主干 | 1 月 3 日)

链接

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

OOLua 编译错误

问题

如何修复?

解决方案

class foo{民众:内部酒吧(){返回0;}};OOLUA_CLASS_NO_BASES(foo)//类没有基OOLUA_NO_TYPEDEFSOOLUA_MEM_FUNC_0(int,bar)OOLUA_CLASS_ENDEXPORT_OOLUA_FUNCTIONS_1_NON_CONST(foo/*类名*/,bar)/*函数被暴露*/EXPORT_OOLUA_FUNCTIONS_0_CONST(foo)无效测试(){OOLUA::Script s;s.register_class();}

解决方案

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/*类名*/,bar)/*函数被暴露*/EXPORT_OOLUA_FUNCTIONS_0_CONST(foo)

Code

#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>();
}

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)

这篇关于OOLua 链接错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆