Dear SketchUp gurus,
I am working on the update of an old project, originally compatible with SU up to 2016.
At the moment I am having problems with yajl-ruby. I have looked at the forum extensively but before integrating the entire yajl-ruby gem or yajl into my extension, I wanted to know if I tried all possible ways to have it working as a gem.
I am using Sketchup2019 Pro on Windows 10.
In order of events this is what happened:
yajl is not found (note that even if we talk about yajl-ruby, the require invokes yajl, but this is normal)
installation fails and yajl still not found
(note that there is also a “yajl” gem in rubygems but it doesn’t do what the original yajl does. However it installs without problems and it loads. Problems arrive when one wants to use the yajl original functions)
attempt to install into my system Ruby 2.6.6 x64. This would not work at the beginning but would then work with
gem install yajl-ruby --platform=ruby
install into Ruby 2.5.8 (both x86 and x64, managed with uru ) and copy to Gem64 folder. Then load into path following Dan’s advice
when doing this, after requiring the library from Console, I get for
Error: #<LoadError: 193: %1 is not a valid Win32 application.
attempted to use
rake-compilerand tweak stuff in gemspecs and rakefile but I might have problems for x64 (not sure I even need 64 bit gems, but I understood from the forum that I do). Followed similar procedure to load but no good results.
attempted to use rake-compiler-dock and follow similar load procedure. Again problems with the x64 version when trying to set
RCD_PLATFORMbefore calling the dock image as in github Readme. The way to pass this variable is not recognized. If I set it afterwards to RCD_PLATFORM=x64-mingw32 once in the docked environment it seems not to complain but it still builds for i386.
found very nice solution to build binaries with gem-compiler by luislavena. After fetching and compiling with gem-compiler I install the gems from local into my rubies and then I copy them from my two ruby versions to Gem64 folder. Attempted loading both of them individually from console, but same error when I require yajl.
I am aware that the advice is to wrap the gems into the extension’s namespace (or rather put the C code in another Ruby C extension) but before doing this I still have some questions.
Is there any reason why the custom gem folder for SU2019 is called Gem64? Is there any place for gems with x86-mingw32 binaries inside? Could it be some trouble with the C code not compatible with x64?
Can it be that I have to install the gems with binaries also in SU? Not just in my ruby > copy to Gem64 > add to LOAD_PATH temporarily > require? (this is just for testing whether it could work, not final sustainable solution)
If none of these can work (for reasons I hope can be clearer), is it better to wrap yajl-ruby as it is with its yajl.so into the extension, or create another C Ruby extension which points to the original yajl ANSI C library (or is it equivalent)? I have managed to successfully require another library in need of Ruby update from 2.0.0 in this way based on the updated template for Ruby 2.5. The case for yajl-ruby might be more complex though.
Is there any reason to believe that using gem-compiler from Ruby 2.5.8 would create binaries with problems for Ruby 2.5.5 used by SU2019?
If anyone would like to understand what’s going on with yajl-ruby and SU2019 (and maybe yajl problems), that would be greatly appreciated! If so, I would suggest the gem-compiler since it has the nicest workflow so far and it shouldn’t take long to test.
Regarding the original yajl, I have built it again from source in Visual Studio but I got a yajl.dll and not a .so file. Which one would it better to use if our plugin users are necessarily on windows? Is it possible to use dlls if one goes with the Ruby C SketchUp approach?
Please correct me if I said something wrong and sorry if there might have been other threads with possible solutions. I really looked through many of them! I am here to learn
P.S. I am a new user so I am not allowed more than 2 hyperlinks… also the post was hidden when I tried to include the links in the reply!