swig Nothing known about base class 'std::string', ignored

别等时光非礼了梦想. 提交于 2019-12-19 23:20:53

问题


I am trying to use swig to build ruby wrappers around a c++ library. Most of it seems to be working but I have one issue that I am pretty sure is related to the above warning.

It looks like one of the classes I am wrapping is inherited from std::string.

I see the above warning message when I run swig.

When I call a method on an object in ruby that should be returning a string, I see this

SWIG::Type_p_std__string:0x.....

I am thinking I need to some how fix the above warning to the this to work, any ideas?


回答1:


SWIG is complaining that it doesn't know about the the std::string class and so cannot generate code for it.

The SWIG library std_string.i has language specific code for mapping the c++ string to the target languages string class. Adding %include "std_string.i" before the code that generates your class should fix the error.

Note that %include is different from #include in a swig interface file.




回答2:


Whenever you see SWIG::Type_p_std__string or similar cryptic type in SWIG output, it means there is a typemap missing. Here, SWIG needs to export std::string. Normally this is because it is used in a function call parameter or as a return value in a function you are exporting; in your case, it is because std::string is a base class. SWIG includes a "library" of typemaps for commonly used STL classes such as string and vector, you simply import it via an %include directive. See http://www.swig.org/Doc2.0/Library.html for other .i that are included with SWIG.



来源:https://stackoverflow.com/questions/20602734/swig-nothing-known-about-base-class-stdstring-ignored

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!