C++ 调用C++;来自Luabind的成员函数“原因”;找不到匹配的重载";
我已经将一些类导出到DLL中的Luabind,对于这两个类(LuaScriptManager、EventManager),一切都正常工作。 我可以从Lua调用它们的函数,一切都很好,但现在我正在尝试在我的客户机可执行文件中设置一些新类,这些类与DLL链接,到目前为止一点运气都没有 以下是我调用的每个函数的错误消息: 未找到匹配的重载,候选项:void loadResource(ResourceManager&,std::string const&) 类绑定来自:C++ 调用C++;来自Luabind的成员函数“原因”;找不到匹配的重载";,c++,lua,luabind,C++,Lua,Luabind,我已经将一些类导出到DLL中的Luabind,对于这两个类(LuaScriptManager、EventManager),一切都正常工作。 我可以从Lua调用它们的函数,一切都很好,但现在我正在尝试在我的客户机可执行文件中设置一些新类,这些类与DLL链接,到目前为止一点运气都没有 以下是我调用的每个函数的错误消息: 未找到匹配的重载,候选项:void loadResource(ResourceManager&,std::string const&) 类绑定来自: 这种奇怪行为的原因可能是什么?这
这种奇怪行为的原因可能是什么?这是我发给Luabind邮件列表的一封邮件的副本。 我不确定这是否也适用于Windows和DLL,但我有一个类似的例子 在Linux上使用GCC和共享模块的经验:类已注册 使用Luabind,其中仅在该共享库中有效,但导致 如果跨共享库边界使用分段错误 解决方案是修补luabind::type_id类,并比较 使用typeid(T).name()代替typeid(T)::运算符=。对于GCC来说 typeid运算符可能无法跨共享库工作的原因 这里解释了[1]。在本例中,我加载了共享 带有Lua的require()的库,很遗憾,它没有通过 RTLD_全球至dlopen
[1] http://gcc.gnu.org/faq.html#dso
在其他C++库中出现了Type ID相等问题,例如 在boost::any[2]中,使用相同的修复程序[3],比较typeid(T).name()
[2] https://svn.boost.org/trac/boost/ticket/754
[3] https://svn.boost.org/trac/boost/changeset/56168
可能附加的补丁在DLL的情况下也有帮助
--- include.orig/luabind/typeid.hpp
+++ include/luabind/typeid.hpp
@@ -6,6 +6,7 @@
# define LUABIND_TYPEID_081227_HPP
# include <boost/operators.hpp>
+# include <cstring>
# include <typeinfo>
# include <luabind/detail/primitives.hpp>
@@ -33,17 +34,17 @@
bool operator!=(type_id const& other) const
{
- return *id != *other.id;
+ return std::strcmp(id->name(), other.id->name()) != 0;
}
bool operator==(type_id const& other) const
{
- return *id == *other.id;
+ return std::strcmp(id->name(), other.id->name()) == 0;
}
bool operator<(type_id const& other) const
{
- return id->before(*other.id);
+ return std::strcmp(id->name(), other.id->name()) < 0;
}
char const* name() const
——include.orig/luabind/typeid.hpp
+++include/luabind/typeid.hpp
@@ -6,6 +6,7 @@
#定义LUABIND\u类型ID\u 081227\u水电站
#包括
+#包括
#包括
#包括
@@ -33,17 +34,17 @@
接线员=(类型标识常量和其他)常量
{
-return*id!=*other.id;
+返回std::strcmp(id->name(),other.id->name())!=0;
}
布尔运算符==(类型id常量和其他)常量
{
-return*id==*other.id;
+返回std::strcmp(id->name(),other.id->name())==0;
}
布尔运算符在(*其他.id)之前;
+返回std::strcmp(id->name(),other.id->name())<0;
}
字符常量*name()常量
这是我发送到Luabind邮件列表的邮件副本。
我不确定这是否也适用于Windows和DLL,但我有一个类似的例子
在Linux上使用GCC和共享模块的经验:类已注册
使用Luabind,其中仅在该共享库中有效,但导致
如果跨共享库边界使用分段错误
解决方案是修补luabind::type_id类,并比较
使用typeid(T).name()代替typeid(T)::运算符=。对于GCC来说
typeid运算符可能无法跨共享库工作的原因
这里解释了[1]。在本例中,我加载了共享
带有Lua的require()的库,很遗憾,它没有通过
RTLD_全球至dlopen
[1] http://gcc.gnu.org/faq.html#dso
在其他C++库中出现了Type ID相等问题,例如 在boost::any[2]中,使用相同的修复程序[3],比较typeid(T).name()
[2] https://svn.boost.org/trac/boost/ticket/754
[3] https://svn.boost.org/trac/boost/changeset/56168
可能附加的补丁在DLL的情况下也有帮助
--- include.orig/luabind/typeid.hpp
+++ include/luabind/typeid.hpp
@@ -6,6 +6,7 @@
# define LUABIND_TYPEID_081227_HPP
# include <boost/operators.hpp>
+# include <cstring>
# include <typeinfo>
# include <luabind/detail/primitives.hpp>
@@ -33,17 +34,17 @@
bool operator!=(type_id const& other) const
{
- return *id != *other.id;
+ return std::strcmp(id->name(), other.id->name()) != 0;
}
bool operator==(type_id const& other) const
{
- return *id == *other.id;
+ return std::strcmp(id->name(), other.id->name()) == 0;
}
bool operator<(type_id const& other) const
{
- return id->before(*other.id);
+ return std::strcmp(id->name(), other.id->name()) < 0;
}
char const* name() const
——include.orig/luabind/typeid.hpp
+++include/luabind/typeid.hpp
@@ -6,6 +6,7 @@
#定义LUABIND\u类型ID\u 081227\u水电站
#包括
+#包括
#包括
#包括
@@ -33,17 +34,17 @@
接线员=(类型标识常量和其他)常量
{
-return*id!=*other.id;
+返回std::strcmp(id->name(),other.id->name())!=0;
}
布尔运算符==(类型id常量和其他)常量
{
-return*id==*other.id;
+返回std::strcmp(id->name(),other.id->name())==0;
}
布尔运算符在(*其他.id)之前;
+返回std::strcmp(id->name(),other.id->name())<0;
}
字符常量*name()常量
Ok我把范围缩小到:如果在DLL中打开lua状态=不工作,如果在客户端exe中打开lua状态=工作。但我当然希望两者的状态相同,这样我就可以在它们之间共享对象……这可能是一个名称损坏问题吗?好的,我已经把它缩小到:如果在DLL中打开的lua状态=不工作,如果在客户端exe中打开的lua状态=工作。但我当然希望两者都有相同的状态,这样我就可以在它们之间共享对象……这会是一个名称混乱的问题吗?