3 Replies Latest reply on May 15, 2015 11:48 PM by Deepali Singh

    Having trouble including BigDecimal

    Tom Carvin

      I'm trying to utilize BigDecimal in a RhoMobile app I have inherited, but I cannot seem to successfully use it.  A simple require is all I need from IRB, but things are not so simple with RhoMobile.  No ruby background, so I've hit the wall.  I've located the gem on my system and it appears to include both ruby and C as part of the implementation, so I don't think I can just drop it into the application.  Any tips on including it would be appreciated!

        • Re: Having trouble including BigDecimal
          Jon Tara

          No, you can't just drop it in. You'll need to create a a native extension.


          Pure ruby is easy - you just extract the lib directory from the Gem. (OK, not so easy if the Gem you are interested in has a bunch of dependencies...)


          For BigDecimal, you will need to make a native extension. Start here:


              Rhomobile | Building a native extension


          This one looks easy. Looks like it's a single C file.


          Pretty sure there are some additional resources including video,  screencast, examples. Maybe the RhoMobile folks can weigh-in here.


          What version of Rhodes? Make sure you follow the docs for the right version. Since 4.0+ it is different, but still supports old extensions at least for now. (Unless you need iOS 64-bit...)


          In fact, the next couple of days, I will be converting a 3.x native extension (Objective-C) to 5.x, because I need it to build for iOS 64-bit. (Currently needs SP3 branch from Git, apparently not quite ready for release.)


          Please consider open-sourcing your extension when you are done! (You might want to Google or search on GitHub to see if somebody else has done so already.)


          Note: Rhodes uses Ruby 1.9.2-p290 internally (regardless of what version you might use to build Rhodes - you need Ruby to build Rhodes only because the build process uses Ruby tools too)


          So make sure you grab a version that will work with that. It's good to have a copy of 1.9.2-p290 installed (use rvm) for testing. It's useful for many things, e.g. just testing out some code that you will use in your app, and so you can first test it on desktop with the exact same version. (Realize that some libraries are missing in Rhdoes, etc. though.)


          So, to clarify, what I would first do is to install Ruby 1.9.2-p290 on your development machine using rvm. Create a GemSet and install the BigDecimal gem there. Now you know that you have a compatible BigDecimal. Go grab it from the Gem and follow the instructions in Building a native extension from the link above.

          • Re: Having trouble including BigDecimal
            Deepali Singh

            Hi Tom,


            Any luck incorporating BigDecimal library in Rhodes? I am trying to do the same but failing, as the library has got bunch of dependencies.


            Thank you in advance.