SWIG:Ruby 重载问题
我有一个 sinatra Web 应用程序和一个 C++ 库,我可以使用创建的绑定在 sinatra (ruby) 中“需要”它们通过痛饮。
我还有第二个非常相似的库,其中函数名称与第一个库部分相同。当我需要它们时,首先加载的那个“获胜”,即对不明确函数名称的调用始终映射到该库。
原因是“require”仅加载尚未加载的内容,而“load”无论如何都会重新加载。但是,“load”似乎不适用于 .so 文件,仅适用于 ruby 源文件。有什么帮助吗?
谢谢
I have a sinatra web application and a C++ library that I can 'require' in sinatra (ruby) using bindings created by swig.
I also have a second -very similar- library, in which the function names are partially the same as in the first one. When I require them both, the one that is loaded first 'wins', i.e. calls to the ambiguous function names are always mapped to this library.
The reason is that 'require' does only load stuff that is not already loaded, whereas 'load' reloads no matter what. However, 'load' seems not to be applicable to .so files, only to ruby source files. Any help?
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
require
在 $" 数组中查找以确定模块 是否应该重新加载。 您可以尝试删除它并要求。不过,不确定这是否适合您的用例,因为名称空间似乎仍然会受到污染。require
looks in $" array to determine if a module should be reloaded. You could try deleting it and requiring. Not sure if this will work for your use case, though, as it seems that the namespace still can be left polluted.