我有一些在 DLL 中导出到 Luabind 的类,这两个类(LuaScriptManager、EventManager)一切正常。我可以从 Lua 调用他们的函数,一切都很好,但现在我试图在我的客户端可执行文件中设置一些新的类,它与 DLL 链接,到目前为止完全没有运气。
这是我调用的每个函数的错误消息:“未找到匹配的重载,候选:void loadResource(ResourceManager&, std::string const&)”
类绑定来自http://www.nuclex.org/articles/5-cxx/1-quick-introduction-to-luabind:
struct Manager {
Manager() :
m_ResourceCount(0) {}
void loadResource(const std::string &sFilename) {
++m_ResourceCount;
}
size_t getResourceCount() const {
return m_ResourceCount;
}
size_t m_ResourceCount;
};
static Manager MyResourceManager;
void Bind(lua_State* l)
{
// Export our class with LuaBind
luabind::module(l) [
luabind::class_<Manager>("ResourceManager")
.def("loadResource", &Manager::loadResource)
.property("ResourceCount", &Manager::getResourceCount)
];
luabind::globals(l)["MyResourceManager"] = &MyResourceManager;
}
这是相应的lua测试代码:
-- The following call will fail with the above error
MyResourceManager:loadResource("abc.res")
--MyResourceManager:loadResource("xyz.res")
-- If the function is commented out, this will work (accessing the property)
ResourceCount = MyResourceManager.ResourceCount
-- Calling my other classes' functions work fine
LuaScriptManager.GetInstance():WriteLine(ResourceCount)
这种奇怪行为的原因可能是什么?