Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何解决LNK2005:已定义 我正在和Lua和Luabind一起做一个C++的项目。现在,在我想导出到C++的每一个类中,我都写了一个静态方法登记:_C++_Lua_Linker Errors_Luabind - Fatal编程技术网

如何解决LNK2005:已定义 我正在和Lua和Luabind一起做一个C++的项目。现在,在我想导出到C++的每一个类中,我都写了一个静态方法登记:

如何解决LNK2005:已定义 我正在和Lua和Luabind一起做一个C++的项目。现在,在我想导出到C++的每一个类中,我都写了一个静态方法登记:,c++,lua,linker-errors,luabind,C++,Lua,Linker Errors,Luabind,在按钮h中: static luabind::scope Register(); 在Button.cpp中: luabind::scope falcon::Button::Register() { return luabind::class_<Button, Button*>("Button") .def(luabind::constructor<float, float, float, float>()); } 有人有什么想

在按钮h中:

static luabind::scope Register();
在Button.cpp中:

luabind::scope falcon::Button::Register()
{
    return 
        luabind::class_<Button, Button*>("Button")
        .def(luabind::constructor<float, float, float, float>());
}

有人有什么想法吗

我刚刚通过在headerfile中定义和声明函数解决了这个错误。。。也许任何人都可以向我解释为什么这门课要这么做,而不是我想在Lua注册的其他10门课


这有点奇怪,因为我在.cpp中的其他类中实现了该函数…

问题不在于所示的静态函数。不知何故,您正在将命名的外部函数的重复定义拉入包含按钮的转换单元中。您需要发布更多代码或手动查看该TU中的包含内容您希望我发布Button类中的所有代码吗?我希望您将焦点转移到问题的根源:)如何呈现它,我不知道,因为我没有你的代码…比前面的注释稍微少一点神秘:看起来你可能在一个文件中显式地包含Button.cpp——可能是因为Button.cpp有模板化的对象或函数——然后Button.cpp被单独编译。因此,每个非模板化函数都会出现重复的符号错误。Button.cpp本身没有模板化对象或函数。luabind::class_u确实有模板化函数,所以可能与此有关?!我检查了我的include,但没有明确显示include Button.cpp的位置,所以我能想到的唯一错误源是luabind本身。。。我来看看:)
1>luabindd.lib(luabindd.dll) : error LNK2005: "public: __thiscall luabind::detail::class_base::~class_base(void)" (??1class_base@detail@luabind@@QAE@XZ) already defined in Button.obj
1>luabindd.lib(luabindd.dll) : error LNK2005: "public: __thiscall luabind::detail::function_object::function_object(int (__cdecl*)(struct lua_State *))" (??0function_object@detail@luabind@@QAE@P6AHPAUlua_State@@@Z@Z) already defined in Button.obj
1>luabindd.lib(luabindd.dll) : error LNK2005: "public: virtual __thiscall luabind::detail::function_object::~function_object(void)" (??1function_object@detail@luabind@@UAE@XZ) already defined in Button.obj
1>luabindd.lib(luabindd.dll) : error LNK2005: "public: __thiscall luabind::detail::invoke_context::operator bool(void)const " (??Binvoke_context@detail@luabind@@QBE_NXZ) already defined in Button.obj
1>luabindd.lib(luabindd.dll) : error LNK2005: "public: __thiscall luabind::detail::invoke_context::invoke_context(void)" (??0invoke_context@detail@luabind@@QAE@XZ) already defined in Button.obj
1>luabindd.lib(luabindd.dll) : error LNK2005: "public: void __thiscall luabind::detail::object_rep::set_instance(class luabind::detail::instance_holder *)" (?set_instance@object_rep@detail@luabind@@QAEXPAVinstance_holder@23@@Z) already defined in Button.obj
1>luabindd.lib(luabindd.dll) : error LNK2005: "public: void * __thiscall luabind::detail::object_rep::allocate(unsigned int)" (?allocate@object_rep@detail@luabind@@QAEPAXI@Z) already defined in Button.obj
1>luabindd.lib(luabindd.dll) : error LNK2005: "public: class luabind::detail::class_rep * __thiscall luabind::detail::object_rep::crep(void)" (?crep@object_rep@detail@luabind@@QAEPAVclass_rep@23@XZ) already defined in Button.obj
1>luabindd.lib(luabindd.dll) : error LNK2005: "public: class luabind::detail::cast_graph const & __thiscall luabind::detail::class_rep::casts(void)const " (?casts@class_rep@detail@luabind@@QBEABVcast_graph@23@XZ) already defined in Button.obj
1>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>D:\Users\THijs\Dropbox\3DAE\Platform Development\Falcon Engine\main\FalconEngine\Debug\FalconEngine.exe : fatal error LNK1169: one or more multiply defined symbols found