1

I am using windows 7 (64) , Ruby(Ruby200-x64) and swig(swigwin-2.0.10) .

I have tried recreating a simple example listed in the SWIG Pages. http://stuff.mit.edu/afs/athena/astaff/project/svn/src/swig-1.3.25/Examples/ruby/class/index.html

I followed the step by step procedure from How to create a DLL with SWIG from Visual Studio 2010 modifying it for the case of Ruby .

When i build the release version of the project , I am getting an error

C:\Dev-Cpp\include\stddef.h(6): fatal error C1021: invalid preprocessor command 'include_next' .

Also while running examples in visual studio 2012,Example (Examples/Ruby/SIMPLE) from the list provided ,Eventhough I have set all the environment variables properly ,Iam getting the following error :

 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 : ')'

Please Help. I am a noob at SWIG ! Thanks .

Community
  • 1
  • 1
Rasika Vijay
  • 395
  • 1
  • 7
  • 17

1 Answers1

1

The example from the link was C++, but the error message suggests SWIG was run without the -c++ flag. The SWIG wrapper was called example_wrap.c instead of example_wrap.cxx.

Try adding that switch to the SWIG command line.

Mark Tolonen
  • 166,664
  • 26
  • 169
  • 251
  • Thanks a lot ! But now I am getting the following error 1>example_wrap.cxx(1119): error C3861: 'rb_obj_classname': identifier not found 1>example_wrap.cxx(1341): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1> d:\ruby\lib\ruby\1.6\i586-mswin32\config.h(4) : see previous definition of 'inline' 1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xkeycheck.h(238): warning C4005: 'volatile' : macro redefinition VC\include\xkeycheck.h(242): fatal error C1189: #error : The C++ Standard Library forbids macroizing keywords. – Rasika Vijay Sep 27 '13 at 09:53
  • Does your c++ class example compile on its own? I don't know Ruby or have it installed, but ask a new question and post a complete, minimal example (.i, .cpp, .h, swig and compile commands) that someone can compile to reproduce the error and I'm sure someone can answer. – Mark Tolonen Sep 27 '13 at 11:46