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

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