• Login
sketchucation logo sketchucation
  • Login
πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Programming in C, C++ for Mac and Windows?

Scheduled Pinned Locked Moved Developers' Forum
51 Posts 9 Posters 8.2k Views 9 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.
  • C Offline
    Chris Fullmer
    last edited by 21 Jan 2010, 19:59

    Sorry to get everyone so riled up around here. Lets not be bashful, dig out those old skeletons from the cloest.....oh wait, we already are!

    The point of this thread is in fact SU based, and about how to write extensions for SU ruby. Or how to interface into SU from another program, or dll, etc. I really am not sure what my question is because I just don't know what is possible, and I don't have a specific task in mind that I am striving to find a solution for (yet!). I just want to broaden my horizons and I want to do it with a compiled language.

    But I will say that I have installed a few compilers and such and I am reading up on C++ currently. But it gives a bit of background into C, C# and Java. Hopefully I'll be able to wrap my head around it.

    Chris

    Lately you've been tan, suspicious for the winter.
    All my Plugins I've written

    1 Reply Last reply Reply Quote 0
    • T Offline
      toxicvoxel
      last edited by 22 Jan 2010, 00:02

      @adamb said:

      The thread is about producing Extensions for Ruby (which is written in C).
      Really? I thought the opening line of the starter post was related to interfacing SU with external .dll's - which can be written with a variety of languages. Seen within that broader premise I think the comments would be misleading to novices looking for an unbiased opinion about selecting a language.

      @unknownuser said:

      It's all well saying Mono, but the reality is that on a Mac, Xcode has great support for C/C++ and not Mono/C#.

      You may notice that my response was in context with the statement that .NET code cannot run cross platform, so I am at a loss to understand the logic of your point. Does XCode run on Windows platforms yet?, - I didn't know, nor does it matter as my design workflow is Windows based.

      TBD, not sure what you want to know.- I have written a number of external .dlls that I interface with from Sketchup as part of my daily workflow, so I can assure you that it is possible, if you are suggesting that it can't be done.

      1 Reply Last reply Reply Quote 0
      • T Offline
        toxicvoxel
        last edited by 22 Jan 2010, 11:13

        @unknownuser said:

        and I am reading up on C++ currently.. But it gives a bit of background into C, C# and Java

        That may take some time... πŸ˜‰
        .

        1 Reply Last reply Reply Quote 0
        • T Offline
          toxicvoxel
          last edited by 23 Jan 2010, 22:12

          A positive idea that can be spun off from this thread would be to create a 'Ruby extendibily' subsection where developers could post sample 'How To..' code for linking SU to external applications, libraries, databases & web-services etc., through native extensions, Win32API, WIN32OLE, file IO, SOAP, and custom bridges etc. For example : Linking SU to Excel, SQL databases, XML, text files, connecting to a web services, linking to CAD. etc
          Starter code for interaction of SU Ruby with external libraries created with the plethora of languages in use could be posted over time by coders proficient in those languages. Such a code repository would be invaluable to existing developers proficient in other languages who wish to use Ruby to glue Sketchup to existing code and applications. This could also serve as a catalyst for seeing more plugins and extensions becoming available over time.
          [- And for novices the sample code could help to inform a choice for selection of a supporting coding language.)

          1 Reply Last reply Reply Quote 0
          • C Offline
            Chris Fullmer
            last edited by 24 Jan 2010, 01:59

            I think that is a neat idea. If I ever make something usef-able I will post it. It looks to be a long ways off at the rate I am moving, but all things are possible. πŸ˜„

            Chris

            Lately you've been tan, suspicious for the winter.
            All my Plugins I've written

            1 Reply Last reply Reply Quote 0
            • T Offline
              toxicvoxel
              last edited by 24 Jan 2010, 02:10

              A summary of this topic should go onto that list for example:
              http://forums.sketchucation.com/viewtopic.php?f=180&t=25233

              1 Reply Last reply Reply Quote 0
              • T Offline
                thomthom
                last edited by 28 Mar 2010, 16:13

                I am extremely green to C/C++.
                Currently doing some very basic tests in C++ with VS2010.

                There is some number crunching that I'd like to do in C++. I did some comparisons and the Ruby version was 100 slower than the C++ version. So I am very interested in finding a way where I can create a set of number crushing methods in C++ which I can call from SU Ruby.

                What I am looking at at the moment is:

                • Sending two arrays of 3D co-ordinates to the C++ method (3D points can be simple array of three floats)
                • Have the C++ method do its thing
                • return a new array back to ruby

                Does it simplify much if the C++ never have to access any SU objects? Is it then possible to create a Windows and OSX solution? Would it be a DLL on Windows and ... what does OSX use...?

                The SUExt link in TDB's post (http://forums.sketchucation.com/viewtopic.php?f=180&t=25201#p216233) leads to a wiki page... ❓

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

                1 Reply Last reply Reply Quote 0
                • T Offline
                  tbd
                  last edited by 28 Mar 2010, 20:13

                  1. see remus response
                  2. PellesC is my favourite - small, fast, free, doesn't install in all your machine, comes with all tools needed. it is C99 compliant

                  I went via VStudio only when I complied some SU SDK programs - too many VS dependent crap to convert it to another compiler

                  1. you need a compiler that creates Mac binaries and PellesC is not one of them 😞
                    but on Mac you have IDE, compiler, debugging tools, Ruby by default so get one.

                  my suggestion:

                  • get a Mac - you can install Windows in bootcamp or virtualized if you want it
                  • start with C, it is easier to debug ruby libraries problems (there are a lot, see Adam's comments)
                  • compile my SUExt example and play with it for start

                  SketchUp Ruby Consultant | Podium 1.x developer
                  http://plugins.ro

                  1 Reply Last reply Reply Quote 0
                  • T Offline
                    tbd
                    last edited by 28 Mar 2010, 20:13

                    link updated in my original post to http://github.com/TBD/OpenSUP/tree/master/SUExt/

                    SketchUp Ruby Consultant | Podium 1.x developer
                    http://plugins.ro

                    1 Reply Last reply Reply Quote 0
                    • T Offline
                      thomthom
                      last edited by 28 Mar 2010, 20:56

                      @unknownuser said:

                      link updated in my original post to http://github.com/TBD/OpenSUP/tree/master/SUExt/

                      cheers.
                      Can one download from one branch? I only managed to find a download for the whole lot. (not that it was a big download - just curious)
                      Also - is that extension one that integrates with SU such that you can access SU objects from C?

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

                      1 Reply Last reply Reply Quote 0
                      • T Offline
                        tbd
                        last edited by 28 Mar 2010, 22:42

                        @thomthom said:

                        Can one download from one branch? I only managed to find a download for the whole lot. (not that it was a big download - just curious)

                        nope. only if I create the .zip myself and add them to Downloads tabs.

                        @thomthom said:

                        is that extension one that integrates with SU such that you can access SU objects from C?

                        is that extension that only extends Ruby with C code (so the title is a bit misleading for now). you can access SU objects via normal Ruby commands (rb_ functions)

                        SketchUp Ruby Consultant | Podium 1.x developer
                        http://plugins.ro

                        1 Reply Last reply Reply Quote 0
                        • T Offline
                          thomthom
                          last edited by 29 Mar 2010, 09:29

                          Would the code be simpler if it didn't integrate Ruby?
                          If it only passed data back and forth? Or is it required to integrate in order to share the various data types?

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

                          1 Reply Last reply Reply Quote 0
                          • T Offline
                            tbd
                            last edited by 29 Mar 2010, 14:24

                            @thomthom said:

                            Would the code be simpler if it didn't integrate Ruby?

                            you dont integrate Ruby, just the needed headers for Ruby types. as you can see the output .so is small, 10kb, without any size optimizations.

                            @thomthom said:

                            If it only passed data back and forth? Or is it required to integrate in order to share the various data types?

                            you only pass data back and forth.

                            SketchUp Ruby Consultant | Podium 1.x developer
                            http://plugins.ro

                            1 Reply Last reply Reply Quote 0
                            • T Offline
                              thomthom
                              last edited by 29 Mar 2010, 22:02

                              And what about Classes defined by SketchUp? How does one handle them?

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

                              1 Reply Last reply Reply Quote 0
                              • T Offline
                                tbd
                                last edited by 30 Mar 2010, 11:03

                                you can use rb_funcallX (see Ruby Interpretor Interface) to call methods from the classes or you can use array/hashes to pass data

                                SketchUp Ruby Consultant | Podium 1.x developer
                                http://plugins.ro

                                1 Reply Last reply Reply Quote 0
                                • T Offline
                                  thomthom
                                  last edited by 30 Mar 2010, 11:17

                                  Say I got a collection of Point3d, Vector3d. Would it be best to convert those to arrays of basic numbers in Ruby and passing onto C? Or would it really not matter?

                                  
                                  static VALUE test(VALUE vector)
                                  {
                                    VALUE arr;
                                    arr = rb_funcall(vector, rb_intern("to_a"), 0)
                                  }
                                  
                                  

                                  This would leave me with arr being an Ruby Array representing the vector, right?
                                  I see there are rb_each and rb_iterate - should one use ruby iterators to loop through Ruby Arrays in C? Or can one use regular C loops?

                                  Are there further reading than this page: http://www.ruby-doc.org/docs/ProgrammingRuby/html/ext_ruby.html

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

                                  1 Reply Last reply Reply Quote 0
                                  • T Offline
                                    tbd
                                    last edited by 30 Mar 2010, 11:56

                                    @thomthom said:

                                    This would leave me with arr being an Ruby Array representing the vector, right?

                                    right

                                    @thomthom said:

                                    I see there are rb_each and rb_iterate - should one use ruby iterators to loop through Ruby Arrays in C? Or can one use regular C loops?

                                    definitely rb_ functions as you are manipulating an array of pointers (VALUE objects)

                                    SketchUp Ruby Consultant | Podium 1.x developer
                                    http://plugins.ro

                                    1 Reply Last reply Reply Quote 0
                                    • T Offline
                                      thomthom
                                      last edited by 30 Mar 2010, 12:42

                                      I am confused again now. I got Pellets. And I did what the article said about generating a makefile. But I'm confused to how I compile it.
                                      From what I understand, make is a UNIX command?

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

                                      1 Reply Last reply Reply Quote 0
                                      • T Offline
                                        thomthom
                                        last edited by 30 Mar 2010, 13:05

                                        Ok, getting close I think, - from the Pelles C Project options I added C:\Ruby\lib\ruby\1.8\i386-mswin32 to the includes path.

                                        But now I get:
                                        Building helloworld.obj. C:\Ruby\lib\ruby\1.8\i386-mswin32\config.h(2): fatal error #1014: #error: MSC version unmatch. *** Error code: 1 *** Done.

                                        ❓

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

                                        1 Reply Last reply Reply Quote 0
                                        • T Offline
                                          thomthom
                                          last edited by 30 Mar 2010, 13:10

                                          Pelles crashed on me - and I swear I heard Homer Simpson's "doh!" as it crashed... 😲 πŸ˜†


                                          error.png

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

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

                                          Advertisement