I have a protobuf_c.so file. It is working with require as below:
Now, I need to encrypt my plugin. So to change the require to Sketchup.require:
But I get the error:
Could not find included file 'google/protobuf_c'
How can I fix it?
It should load Ruby C Extensions, yes. Hard to say what is going on without a complete example to test.
Though, you only need to use
Sketchup.require when referring to
.rb files, since they are the only files being replaced during encryption.
Sketchup::require does not search for
so files. The documentation states:
This method will look for
.rbe first (encrypted) and then
.rbs (the deprecated scrambled format) and finally
.rb (unencrypted) files.
So have your code use the global
require method for loading
.dylib library files.
Thanks. Yes, I need to use require for .so files instead of Sketchup.require.
Because I do not want to encrypt the google/protobuf lib again, so removing it entirely before encrypting. Then encrypt it to get .rbz to download. Next, unzip the .rbz, restore the google/protobuf. Finally zip all into a .rbz again. The process works, though it is tedious. Especially some mistakes occur when installing the plugin, I have to repeat the whole process again and again.
I would suggest just letting the gem’s
rb files be encrypted.
I would suggest looking into Rake to automate tasks like these. I use the same workflow you describe for my plugin. You can simply pause the Rake task with something like
STDIN.gets.chomp, encrypt and sign the archive, replace it with the encrypted one and then proceed with the task.
You could also automate the signing, but this stopped working for me recently.
I checked my own extensions, that’s what I do as well, I use
require for C Extensions, but
SketchUp.require for .rb files. Once you have the requires right you should be good to go.
Thank you very much @Rojj. I will try it out because we need to encrypt frequently our plugin recently.