sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Wrap gem under own namespace

    Scheduled Pinned Locked Moved Developers' Forum
    14 Posts 3 Posters 316 Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • thomthomT Offline
      thomthom
      last edited by

      Aye, I made my own private copy of the Win32 API lib. There is a readme in my distribution. I did however use Ruby 1.8 to build it - since that's what SketchUp uses. Don't think you'll get it working with 1.9.

      I uploaded a C Extension how-to to BitBucket: https://bitbucket.org/thomthom/sketchup-ruby-c-extension

      Thomas Thomassen β€” SketchUp Monkey & Coding addict
      List of my plugins and link to the CookieWare fund

      1 Reply Last reply Reply Quote 0
      • A Offline
        Anton_S
        last edited by

        Thanks Dan, now I see that I wasn't the only one confused with these gems compiling thing.

        Thomthom, thanks, the example is excelent! And by the way, that idea of Win32::API, under own namespace came from that same TT_Lib2. Don't worry though, I'm not dismantling your TT_LIb to pieces. πŸ˜„

        To make sure, if I have Anton::Win32::API and Wi32::API, then the Anton::Win32::API::Callbacks.new limit would not count callbacks from standard Win32::API, right? So, If I create to callbaks on Win32::API and 10 on Anton::Win32::API, then it will work?

        1 Reply Last reply Reply Quote 0
        • A Offline
          Anton_S
          last edited by

          @unknownuser said:

          1. Navigate to the project folder
          2. Execute "ruby extconf.rb"
          3. Execute "make"

          Need more info on these parts. I opened the Visual Studia 2010 Command Prompt via start menu, but then don't know the EXACT commands to write into the prompt; How do I navigate, and how do I execute, pls. I'm beginner! 😳

          1 Reply Last reply Reply Quote 0
          • thomthomT Offline
            thomthom
            last edited by

            @anton_s said:

            So, If I create to callbaks on Win32::API and 10 on Anton::Win32::API, then it will work?

            Would it not be better to adjust the limit of callbacks in your customized Anton::Win32::API instead of spreading across multiple API modules?

            @anton_s said:

            How do I navigate, and how do I execute, pls. I'm beginner! 😳

            Ah, you've never used DOS, have you?

            To navigate you use the cd command (change directory). To execute you just type the name of the executable - the bat file.

            So, something like this:

            cd "C:\path\to\my\project" (Return)
            ruby extconf.rb (Return)
            make

            Thomas Thomassen β€” SketchUp Monkey & Coding addict
            List of my plugins and link to the CookieWare fund

            1 Reply Last reply Reply Quote 0
            • A Offline
              Anton_S
              last edited by

              @thomthom said:

              Would it not be better to adjust the limit of callbacks in your customized Anton::Win32::API instead of spreading across multiple API modules?

              Sure, I'll try to increase callbacks limit in api.c.

              Got a little proplem here compiling thomthoms c-extention example:
              Some strange error
              Some probable cause:

              • Installed ruby 1.8.6 patchlevel 398.
              • Did NOT find these lines in config.h.
                #if _MSC_VER == 1200
                #error MSC version unmatch
                #endif
              • Have MSFT Visual Studio 10.0
              1 Reply Last reply Reply Quote 0
              • thomthomT Offline
                thomthom
                last edited by

                Did you try with the one-click installer in the Readme?
                http://rubyforge.org/frs/download.php/47082/ruby186-27_rc2.exe

                I'm not familiar with that error message. And it's odd that you did not find those lines.

                Thomas Thomassen β€” SketchUp Monkey & Coding addict
                List of my plugins and link to the CookieWare fund

                1 Reply Last reply Reply Quote 0
                • A Offline
                  Anton_S
                  last edited by

                  @thomthom said:

                  Did you try with the one-click installer in the Readme?http://rubyforge.org/frs/download.php/4 ... 27_rc2.exe

                  Installed it, found and comment out the first 3 lines.

                  Now, after that I tried it again, everything worked! β˜€
                  It works!!!
                  Thankyou, Thankyou, thankyou!!! πŸ˜„ πŸ‘ πŸ‘

                  1 Reply Last reply Reply Quote 0
                  • thomthomT Offline
                    thomthom
                    last edited by

                    πŸ‘ πŸ‘

                    Thomas Thomassen β€” SketchUp Monkey & Coding addict
                    List of my plugins and link to the CookieWare fund

                    1 Reply Last reply Reply Quote 0
                    • Dan RathbunD Offline
                      Dan Rathbun
                      last edited by

                      @thomthom said:

                      I uploaded a C Extension how-to to BitBucket:

                      Added your example link to the [ Code Snippets ] post:
                      [Info] C/C++ Ruby extensions & SketchUp plugins

                      πŸ€“

                      I'm not here much anymore.

                      1 Reply Last reply Reply Quote 0
                      • A Offline
                        Anton_S
                        last edited by

                        One thing to NOTE, when creating ur own extconf.rb
                        Lets, say you have an extension api.c and decide to create ur own extconf.rb, and so, you do:

                        require 'mkmf'
                        PLATFORM_IS_OSX     = (Object;;RUBY_PLATFORM =~ /darwin/i) ? true ; false
                        PLATFORM_IS_WINDOWS = !PLATFORM_IS_OSX
                        if PLATFORM_IS_OSX
                          CONFIG['LDSHARED'] = 'cc -dynamic -bundle -undefined suppress -flat_namespace'
                        end
                        create_makefile( 'api.c' )
                        

                        The code above looks pretty clean but there is one thing WRONG! In the sting of last line never add the file suffix! That way init_api inside the api.c won't be recognized! So, last line should look like create_makefile( 'api' ).

                        Here is a batch file Extract and Put it into ur project's folder -that will write compiling commands for u. Jst Place it into ur project's folder, change the vcvars32.bat path to your current vcvars32.bat path, and run it to compile.

                        1 Reply Last reply Reply Quote 0
                        • thomthomT Offline
                          thomthom
                          last edited by

                          The string you feed create_makefile should relate to the init function in your C extension.

                          As you see from the Hello World example, extconf contains this:
                          create_makefile( 'SX_HelloWorld' )

                          And in the C source you have the init function:
                          void Init_SX_HelloWorld( void )

                          Note how "Init_" is prepended of the name you feed makefile - and it's case sensitive.

                          @anton_s said:

                          change the vcvars32.bat path to your current vcvars32.bat path, and run it to compile.

                          I have found after making the tutorial that it is easier to just launch the command prompt shortcut that ships with Visual Studio. It's there in it's folder in the start menu. The environment is set up automatically.

                          Thomas Thomassen β€” SketchUp Monkey & Coding addict
                          List of my plugins and link to the CookieWare fund

                          1 Reply Last reply Reply Quote 0
                          • 1 / 1
                          • First post
                            Last post
                          Buy SketchPlus
                          Buy SUbD
                          Buy WrapR
                          Buy eBook
                          Buy Modelur
                          Buy Vertex Tools
                          Buy SketchCuisine
                          Buy FormFonts

                          Advertisement