【问题标题】:Getting started with SWIG-Ruby on windows在 Windows 上开始使用 SWIG-Ruby
【发布时间】:2013-09-23 08:59:13
【问题描述】:

我正在使用 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 的菜鸟!谢谢。

【问题讨论】:

    标签: c++ ruby visual-studio swig build-error


    【解决方案1】:

    链接中的示例是 C++,但错误消息表明 SWIG 在没有 -c++ 标志的情况下运行。 SWIG 包装器被称为 example_wrap.c 而不是 example_wrap.cxx

    尝试将该开关添加到 SWIG 命令行。

    【讨论】:

    • 非常感谢!但是现在我收到以下错误 1>example_wrap.cxx(1119): error C3861: 'rb_obj_classname': identifier not found 1>example_wrap.cxx(1341): error C4430: missing type specifier - int 假定。注意:C++ 不支持 default-int 1> d:\ruby\lib\ruby\1.6\i586-mswin32\config.h(4) :参见之前对“内联”的定义 1>C:\Program Files (x86) \Microsoft Visual Studio 11.0\VC\include\xkeycheck.h(238):警告 C4005:'volatile':宏重新定义 VC\include\xkeycheck.h(242):致命错误 C1189:#error:C++ 标准库禁止宏化关键字。
    • 您的 c++ 类示例是否可以自行编译?我不知道 Ruby 或安装了它,但提出一个新问题并发布一个完整的、最小的示例(.i、.cpp、.h、swig 和编译命令),有人可以编译以重现错误,我是肯定有人能回答。
    猜你喜欢
    • 1970-01-01
    • 2012-07-23
    • 2011-11-10
    • 1970-01-01
    • 2010-11-29
    • 1970-01-01
    • 2023-04-01
    • 2011-03-05
    • 1970-01-01
    相关资源
    最近更新 更多