• Login
sketchucation logo sketchucation
  • Login
🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Cannot get C extensions to run in Sketchup

Scheduled Pinned Locked Moved Developers' Forum
11 Posts 3 Posters 1.8k Views 3 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    Jim
    last edited by 17 Feb 2016, 00:14

    You will want to check out this Github repository[1]

    I hope someone who knows better will correct me, but it is my current understanding that you will need Visual Studio 2010 in order to build compatible .dll files for SketchUp plugins on Windows.

    [1] https://github.com/SketchUp/ruby-c-extension-examples

    Hi

    1 Reply Last reply Reply Quote 0
    • J Offline
      johnzdennis
      last edited by 17 Feb 2016, 01:17

      Thanks Jim,
      I've got that one - I didn't have much luck with it the first go-round but I'll give it another shot and see if maybe I've learned some stuff since I last tried.

      1 Reply Last reply Reply Quote 0
      • J Offline
        johnzdennis
        last edited by 17 Feb 2016, 02:20

        I've nosed around in there and Hello World seems to compile okay on Visual Studio (2015, in my case) but I have no idea what to actually do with any of it - I was hoping for something more of a walkthrough in terms of:

        1. Here's the example repository
        2. Here's what to do to compile it (i.e. compile it via Visual Studio, etc.)
        3. Here's the output that you'll need (directory, .so file, etc.)
        4. Here's how to talk to it with Ruby and make use of it in Sketchup (i.e. put out a UI messagebox with "Hello World")

        I hope I'm not missing anything incredibly obvious, but it's not clear to me as a novice how to progress forward with these materials.

        1 Reply Last reply Reply Quote 0
        • J Offline
          johnzdennis
          last edited by 17 Feb 2016, 03:13

          Curiously, if I compile on a Linux machine, I'm not seeing any joy, but I'm getting a different error:

          require "C:/code/myext/myext"
          Error: #<LoadError: 193: %1 is not a valid Win32 application. - C:/code/myext/myext.so>
          C:/Program Files/SketchUp/SketchUp 2016/Tools/RubyStdLib/rubygems/core_ext/kernel_require.rb:45:in require' C:/Program Files/SketchUp/SketchUp 2016/Tools/RubyStdLib/rubygems/core_ext/kernel_require.rb:45:in require'
          <main>:in <main>' SketchUp:1:in eval'

          1 Reply Last reply Reply Quote 0
          • T Offline
            thomthom
            last edited by 17 Feb 2016, 11:03

            @johnzdennis said:

            Curiously, if I compile on a Linux machine, I'm not seeing any joy, but I'm getting a different error:

            require "C:/code/myext/myext"
            Error: #<LoadError: 193: %1 is not a valid Win32 application. - C:/code/myext/myext.so>
            C:/Program Files/SketchUp/SketchUp 2016/Tools/RubyStdLib/rubygems/core_ext/kernel_require.rb:45:in require' C:/Program Files/SketchUp/SketchUp 2016/Tools/RubyStdLib/rubygems/core_ext/kernel_require.rb:45:in require'
            <main>:in <main>' SketchUp:1:in eval'

            Sounds like you are trying to load a 32bit binary in 64bit SketchUp - or vise-versa. Make sure you check what build config you use. You need to generate separate binaries per bitness. And make sure you aren't trying to load Ruby 1.8 builds in SU versions using Ruby 2.0.

            Thomas Thomassen — SketchUp Monkey & Coding addict
            List of my plugins and link to the CookieWare fund

            1 Reply Last reply Reply Quote 0
            • T Offline
              thomthom
              last edited by 17 Feb 2016, 11:08

              @johnzdennis said:

              but I have no idea what to actually do with any of it

              Do you have something specific in mind for what you want to use Ruby C Extensions for?

              Thomas Thomassen — SketchUp Monkey & Coding addict
              List of my plugins and link to the CookieWare fund

              1 Reply Last reply Reply Quote 0
              • J Offline
                johnzdennis
                last edited by 17 Feb 2016, 17:47

                Thanks - I'll give that a look and see. I originally discounted it since Oily_PNG has survived several Sketchup updates without going sour on me, but it's definitely worth inspecting.

                As far as my purposes, most of what I'm doing will have to do with pixel counting and generating overlay images of PNG's. I can do it fine in Ruby but it's slow; when dealing with larger images I really want something that can kick it into higher gear.

                1 Reply Last reply Reply Quote 0
                • J Offline
                  johnzdennis
                  last edited by 17 Feb 2016, 23:57

                  Well that was hell in a bucket. Thom's advice looks like it was solid; I'd forgotten that I had to install oily_png as a ruby gem and in doing so it compiled for Ruby 2.0.0; that's why it worked. So far I've tried repackaging some C code as a gem and then installing it so it uses the 2.0.0 compiler; that gets a "true" response when I require it from the Sketchup ruby console, so...hooray. Seems like I'm making progress.

                  1 Reply Last reply Reply Quote 0
                  • T Offline
                    thomthom
                    last edited by 18 Feb 2016, 09:52

                    @johnzdennis said:

                    As far as my purposes, most of what I'm doing will have to do with pixel counting and generating overlay images of PNG's. I can do it fine in Ruby but it's slow; when dealing with larger images I really want something that can kick it into higher gear.

                    So you want a C/C++ lib to handle this image manipulation and wrap with with Ruby?

                    Thomas Thomassen — SketchUp Monkey & Coding addict
                    List of my plugins and link to the CookieWare fund

                    1 Reply Last reply Reply Quote 0
                    • J Offline
                      johnzdennis
                      last edited by 18 Feb 2016, 19:16

                      That's the plan.

                      1 Reply Last reply Reply Quote 0
                      • 1 / 1
                      1 / 1
                      • First post
                        11/11
                        Last post
                      Buy SketchPlus
                      Buy SUbD
                      Buy WrapR
                      Buy eBook
                      Buy Modelur
                      Buy Vertex Tools
                      Buy SketchCuisine
                      Buy FormFonts

                      Advertisement