代码之家  ›  专栏  ›  技术社区  ›  HyperCas

OOLua链路错误

  •  0
  • HyperCas  · 技术社区  · 16 年前

    #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>();
    }
    
    1 回复  |  直到 9 年前
        1
  •  1
  •   Georg Fritzsche    16 年前

    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)