我使用的是Windows 7(64),Ruby(Ruby200-x64)和swig(swigwin-2.0.10)。
我尝试重新创建SWIG页面中列出的一个简单示例。 http://stuff.mit.edu/afs/athena/astaff/project/svn/src/swig-1.3.25/Examples/ruby/class/index.html
我遵循了How to create a DLL with SWIG from Visual Studio 2010针对Ruby的情况修改它的分步过程。
当我构建项目的发布版本时,我收到错误
C:\Dev-Cpp\include\stddef.h(6): fatal error C1021: invalid preprocessor command 'include_next' .
同样在Visual Studio 2012中运行示例时,提供的列表中的示例(示例/ Ruby / SIMPLE),尽管我已正确设置了所有环境变量,但是我收到以下错误:
1. 1> RUBY_INCLUDE:
C:\Ruby200-x64\include\ruby-2.0.0;C:\Ruby200-x64\include\ruby-2.0.0\ruby;C:\ruby-1.8.7-p160;C:\ruby-1.8.6-p368;C:\ruby-1.8.7-p160\win32;C:\ruby-1.8.7-p160\vms;C:\ruby-1.8.7-p160\ext\nkf\nkf-utf8
1> RUBY_LIB:
C:\Ruby200-x64\lib\libx64-msvcrt-ruby200.dll.a;C:\Ruby200-x64\bin\x64-msvcrt-ruby200.dll;
1> example_wrap.c
1>c:\ruby200-x64\include\ruby-2.0.0\ruby/encoding.h(87): error
C2146: syntax error : missing ')' before identifier 'obj'
1>c:\ruby200-x64\include\ruby-2.0.0\ruby/encoding.h(87): error
C2061: syntax error : identifier 'obj'
1>c:\ruby200-x64\include\ruby-2.0.0\ruby/encoding.h(87): error
C2059: syntax error : ';'
1>c:\ruby200-x64\include\ruby-2.0.0\ruby/encoding.h(87): error
C2059: syntax error : ')'
请帮助。我是SWIG的菜鸟!谢谢。
答案 0 :(得分:1)
链接中的示例是C ++,但错误消息表明SWIG在没有-c++
标志的情况下运行。 SWIG包装器名为example_wrap.c
而不是example_wrap.cxx
。
尝试将该开关添加到SWIG命令行。