由于想把opencv的一些东西移植到服务器后端上,因此想使用SWIG进行代码的转换,生成一个nodejs的库,过程中遇到如下困难解决了一个上午。。。特此记录,期望可以帮助到更多的小伙伴。
系统:ubuntu 1604
SWIG版本:3.0.12(release 最新)
nodejs版本:10.15.3(最新)
npm版本:6.4.1
v8版本: 6.8+
…/Smooth_wrap.cxx:2006:47: error: ‘WeakCallbackData’ in namespace ‘v8’ does not name a template type
static void _wrap_delete_Line(const v8::WeakCallbackData<v8::Object, SWIGV8_Proxy> &data) {
^
…/Smooth_wrap.cxx:2006:63: error: expected ‘,’ or ‘…’ before ‘<’ token
static void _wrap_delete_Line(const v8::WeakCallbackData<v8::Object, SWIGV8_Proxy> &data) {
^
…/Smooth_wrap.cxx: In function ‘void _wrap_delete_Line(int)’:
…/Smooth_wrap.cxx:2007:40: error: ‘data’ was not declared in this scope
v8::Localv8::Object object = data.GetValue();
^
…/Smooth_wrap.cxx: At global scope:
…/Smooth_wrap.cxx:2984:55: error: ‘WeakCallbackData’ in namespace ‘v8’ does not name a template type
static void _wrap_delete_EdgeSmoother(const v8::WeakCallbackData<v8::Object, SWIGV8_Proxy> &data) {
^
…/Smooth_wrap.cxx:2984:71: error: expected ‘,’ or ‘…’ before ‘<’ token
static void _wrap_delete_EdgeSmoother(const v8::WeakCallbackData<v8::Object, SWIGV8_Proxy> &data) {
^
…/Smooth_wrap.cxx: In function ‘void _wrap_delete_EdgeSmoother(int)’:
…/Smooth_wrap.cxx:2985:40: error: ‘data’ was not declared in this scope
v8::Localv8::Object object = data.GetValue();
^
…/Smooth_wrap.cxx: In function ‘void SWIG_V8_SetModule(void*, swig_module_info*)’:
…/Smooth_wrap.cxx:3265:15: error: ‘class v8::Object’ has no member named ‘SetHiddenValue’
global_obj->SetHiddenValue(SWIGV8_STRING_NEW(“swig_module_info_data”), mod);
^
…/Smooth_wrap.cxx: In function ‘swig_module_info* SWIG_V8_GetModule(void*)’:
…/Smooth_wrap.cxx:3271:49: error: ‘class v8::Object’ has no member named ‘GetHiddenValue’
v8::Localv8::Value moduleinfo = global_obj->GetHiddenValue(SWIGV8_STRING_NEW(“swig_module_info_data”));
wget https://git.yoctoproject.org/cgit.cgi/poky/plain/meta/recipes-devtools/swig/swig/0001-Add-Node-7.x-aka-V8-5.2-support.patch
cd /usr/share/swig3.0(or /usr/local/share/swig/VERSION)
sudo patch -p2 <~/0001-Add-Node-7.x-aka-V8-5.2-support.patch