代码
#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)
使用
视觉工作室 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/
问题
如何修复?
解决方案
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>();
}