Getting Ruby C Extensions to work with 64-bit Windows
-
I've downloaded the C extension examples from the repository at github.com/SketchUp/ruby-c-extension-examples and played around with them a bit in Visual Studio 2015.
When I try to build them, the Hello World example builds fine, but when I try to run it in Sketchup I get the following error:
@unknownuser said:
require 'SUEX_HelloWorld'
Error: #<LoadError: 193: %1 is not a valid Win32 application. - C:/code/ruby-c-extension-examples-master/ruby-c-extension-examples-master/Debug (1.8)/SUEX_HelloWorld.so>The SUEX_UsingSWIG fails to build courtesy of a "MSC version unmatch: _MSC_VER: 1600 is expected" error.
I found the following thread http://forums.sketchup.com/t/call-c-from-ruby-in-sketchup/17272/8 with some talk about previous versions of Visual Studio (2010 and 2013) but the current example repository has comments about making changes to allow for a VS2015 so...
I guess my main question is whether I need to make some changes to the Visual Studio project (settings somewhere?) to get it to build for 64 bit (I'm running SketchUp Pro 2016 on 64-bit Windows 10)? Or is there some other issue?
If I can just get the Hello World example to run I'll be off and running, but I've reached the point where I'm stumped. Thanks for any help.
-
Remember to pick the correct build configuration for the SketchUp version you launch.

Not sure about the SWIG project - just remove it if you don't intend to use it.
-
Of course! I feel quite silly (my only defense is that I'm very much a novice with Visual Studio). Thanks very much for the response - in a bit I'll write up a simple walkthrough in case someone else stumbles into this thread in the same situation that I was in.
-
No worries. Nothing is obvious when you are new to it.
We (SketchUp) actually have a tutorial on this planned. Hope to have it published later this fall. -
So I'm running into a new issue; not sure if this has been encountered by anyone else, but building a "Debug" version of SUEX_HelloWorld works fine (Debug 2.0/x64) works fine, but trying to build a "Release" version fails with a bunch of C2375 errors (redefinition; different linkage) for a bunch of geometric functions. SWIG doesn't have the same problem. Any ideas?
-
Check out this issue on the GitHub Repo:
Build failed for Release (2.0) x64 platform · Issue #6 · SketchUp/ruby-c-extension-examples
Using VS Express 2015 for Windows Desktop. I had to change the Runtime Library to use the /MD option instead of the /MT option in order to build SUEXT_HelloWorld for Release (2.0) on the x64 Platform. Properties > C/C++ > Code Generation...
GitHub (github.com)
Thom posted a revised RubyLib.h file that fixes these.
-
HE SHOOTS HE SCORES!
That fixed it - thanks so much!
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register LoginAdvertisement