Beginner Help with SDK - C++ example file and dev environment

Hi All - I’ve been programming with the SU Ruby API for years, very comfortable with that framework. In order to have the flexibility of providing and managing licenses with a new plugin, I’m dipping my toes into the C++ SDK. I have experience programming in C++, but my achilles heel always seems to be getting a project setup, so I hope you’ll bear with me.

I installed Visual Studio 2022 and downloaded a copy of ThomTom’s ruby-c-extension-examples

I want to test in my Pro installation of Sketchup 2023, so the only changes I made to ThomThom’s files so far is to change references to SketchuUp 2017 to SketchUp 2023 in Hello World.vcxproj:

$(ProgramW6432)\SketchUp\SketchUp 2023\SketchUp.exe WindowsLocalDebugger

I have Hello World.vcxproj and Debug (2.7)|x64 as my startup configurations. Visual Studio is being run as an administrator.

When I click the green arrow, I get this error message:

Thank you for any help you can give! I’m a newb at the ruby integration, so instructions on what to do with this example, once it’s running are also welcome :joy:.


Karen

When I still tinkered around with stuff like this, a .so file was a shared library, not an executable. Is this a different kind of .so file specific to SUP or VS or even C?

Edit. Never mind, I’ve been away from that world too long. Disregard. :crazy_face:

1 Like

Remove the word(s) WindowsLocalDebugger.from the Project>Properties>Debugging command and see what happens.

BTW, If the problem is deeper rooted, everything runs swimmingly in VS2019 which you can download from here

Hi @sWilliams - thanks for the response. Things are working better now - I’ll document the details to help anyone else out for the future:

  1. I realized that the formatting did something funny with the html tags in my first post. The lines of Hello World.vcxproj look like this:

  1. I also have Visual Studio 2019 Installed. In the 2019 version, I get the following error:

  1. with some additional googling, it looks like .NET didn’t install with Visual Studio. I uninstalled and re-installed Visual Studio 2019 making sure to install the .NET package this time

  2. When opening the project, select “Open a project or solution”, then open the file: “SketchUp Ruby C Extension Examples.sln”

I’m still figuring out the rest, but the example file now opens Sketchup

There are also a bunch of examples available with the SDK download

FYI: The old C++ SDK was retired many years ago. It was replaced with the current C API.

A reminder of how to post code in various languages in Discourse forums:

The C API introduction page under Build and Release Considerations says …

SketchUp 2020, 2021, 2022, and 2023.0 for Windows were built using Visual Studio 2019, and so plugins should be built with the Platform Toolset set to Visual Studio 2019 (v142).

This seems to indicate a newer version of VS could be used as long as the toolset is set properly for the SketchUp versions targeted by the extension being compiled.

Also, the README for the ruby-c-extension-examples repository explains about a couple of compiler switches that coders should take note of.

There are specific instructions to setting up a SketchUp extension project for VSCode which may also work (in a similar fashion) in full blown VS.

If you will be doing Ruby coding in VS, you may also need the SketchUp Ruby debugger DLL:

… and possibly the Ruby API stubs if you want Intellisense popups within the VS editor:

True. In this case the project compiles a so file meant to be loaded into a Ruby process using Ruby’s global require method.

Such libraries must have a proper C entry point function whose name begins with the prefix Init_ and finishes with the same name as the compiled so file.

For this "SUEX_HelloWorld.so" library file, it’s entry point function must be named: "Init_SUEX_HelloWorld", viz :

.


Ruby itself is implemented in C.

More information about coding Ruby in C can be found in the Writing Extensions in C ebook by Dave Thomas:

.


… and the SketchUp C API has received some functions to pass data back and forth from Ruby ↔ C. See:

The documentation does not say so, but I would guess that points and vectors could be passed back and forth as arrays of numerics (doubles on the C side).

1 Like

Hi @DanRathbun - yes, I’m getting my alphabet soup confused. C SDK, not C++

Thank you for all the resources. I think I’m well on my way.

2 Likes