Is there an example of using gems with c++ language inside an extension?

I currently have a new extension that I’m planning to write, but it requires the use of a gems, I’ve read most of the forum threads about gems, and one of them mentions that it’s recommended to include the source code in your own extension’s namespace to prevent conflicts with other extensions, and I understand that, but…I’m currently a newbie, so I’d like to simply add the corresponding gmes to my plugin, either by installing them at extension runtime or by copying the code into my extension, the bigger problem is that it’s not a pure ruby gems… I have recently had a brief lesson in c++ primer, but I still don’t know how to compile it into . I understand this, but …so files, so, please, do you have any examples of adding gems to a sketchup extension and compiling the .so file to make the extension callable?

Any gems in particular? Not sure if you intend to write your own, or whether you’re referring to gems available from RubyGems.org.

JFYI, you’ll need to compile the gems yourself, and the *.so files are specific to a Ruby ‘major.minor’ build. So, for your extension to work with SU 2024, you’d need to compile with Ruby 3.2, but to work with SU 2021 thru 2023, you’d need to compile with Ruby 2.7.

Lastly, the standard stand-alone Windows Rubies are built with the MSYS2 compile tools, the Ruby used in SketchUp is built with Visual Studio tools. That may cause additional issues, depending on how you compile the C/C++ source.

Yes I need to use gem on rubygems.org, the reason I need it is To implement something that is only available in c++, and I know that the .so files are for different ruby versions, but the hard part for me is how to manipulate … I’ve never used gems in extensions before, and more importantlyHow to compile c++ to make ruby usable?I may have asked a 1+1 = ?the problem is only because I’m not a programming major, just a rookie.So, I might need an example that I can mimic…

What is the specific gem and what is the “something” you need only available in C++ ?

Just to clarify

  1. You can include *.so files in your packaged SU extension.

  2. A user may not have the build tools needed to compile C/C++ source code.

  3. Hence, you should compile the code on your system.

  4. If your code has no purpose outside of SketchUp, there’s no point in hosting it on RubyGems, but nothing stops you from doing so.

Assuming you want to call into your *.so file(s) from Ruby, you need to set up your C/C++ source code to allow that.

See:

Ruby 3.2 ‘Creating Extension Libraries for Ruby’

You can review all the C source code in Ruby, and there are many popular gems that contain C/C++ source.