Making GUIs in C/C++

Discussion in 'Mac Programming' started by jsmwoolf, Sep 8, 2011.

  1. jsmwoolf macrumors regular

    Joined:
    Aug 17, 2011
    #1
    The thing is that even though C/C++ can't naturally create graphic user interfaces(unlike Java), how do companies such as Adobe make suite software if a lot of them are written in C/C++? Do they use a special software that no one else has access to or do they use OpenGL, GTK+, etc. that's open to the public?
     
  2. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #2
    Generally crossplatform software either targets a GUI layer that is portable like GTK or there is a separation between the business logic that is in C/C++, then a platform specific GUI is written per platform that utilizes the common code implementing the logic.

    Also, for now Carbon is still available on OS X, allowing GUIs in C.

    -Lee
     
  3. jsmwoolf thread starter macrumors regular

    Joined:
    Aug 17, 2011
    #3
    Is Carbon going away or something?
     
  4. TCB13 macrumors newbie

    Joined:
    Apr 6, 2008
    #4
    There are some elegant solutions to write a program in C++ and cross compile with for all platform like using a framework like Qt.

    Anyway, most of the time if you're writing a coca app in xCode witch will be writing in Objective-C you can mix C or C++ in the code since gcc is there to compile it.

    In fact Objective-C is just another very elegant extension of C that provides classes and objects and manage UIs and make our life's easier.

    Hope it helps! :apple:

    ----------

    Probably, and you should not be using it. It makes no sense since you can compile C/C++ in a middle of a cocoa app. Also the technologies used by carbon are old and slow today.
     
  5. jsmwoolf thread starter macrumors regular

    Joined:
    Aug 17, 2011
    #5
    I guess I won't use Carbon, but I was questioning it over Cocoa anyway. However, the question is when is it appropriate to use Cocoa vs. another program/GUI compiler? It always depends on what you're trying to do.
     
  6. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #6
    If you're writing only a Mac app, use Cocoa. Otherwise look into the other various cross platform solutions.
     
  7. goMac macrumors 603

    Joined:
    Apr 15, 2004
    #7
    They don't. They write the GUI's in Cocoa. Cocoa can mix with C/C++ no problem.
     
  8. jsmwoolf thread starter macrumors regular

    Joined:
    Aug 17, 2011
    #8
    Yea, but only Objective-C can talk to Cocoa although you can put functions from C/C++ into the program.
     
  9. jiminaus macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #9
    That's not quite right. It is possible for C/C++ to send messages to Objective-C classes and objects using the Objective-C runtime functions. See the Objective-C Runtime Reference.
     
  10. jsmwoolf thread starter macrumors regular

    Joined:
    Aug 17, 2011
    #10
    So would the best solution be GTK?
     
  11. lloyddean macrumors 6502a

    Joined:
    May 10, 2009
    Location:
    Des Moines, WA
    #11
    The "best" solution is always the platform native one. In this case it is Objective-C++ and Cocoa.
     
  12. talmy macrumors 601

    talmy

    Joined:
    Oct 26, 2009
    Location:
    Oregon
    #12
    We use Qt at work for Linux. I recently wanted to make "multi platform" an old C application I had that was written for Windows (so old that it did Windows system calls directly without a toolkit like .Net or MFC). I used Qt and it runs fine on both OS X and Linux.

    Normally, however, I use Java for cross platform development, and have for about 13 years.

    I've found Objective-C reasonable but there is something about Xcode/Objective-C/Cocoa that I just find completely foreign compared to other programming environments I've used over the years. And of course when you are done you have an OS X and/or iOS only application.
     
  13. jsmwoolf thread starter macrumors regular

    Joined:
    Aug 17, 2011
    #13
    How about if I plan on porting applications to different platforms?

    EDIT: Oh, I didn't see your post at the time of posting talmy.
     
  14. Sydde macrumors 68020

    Sydde

    Joined:
    Aug 17, 2009
    #14
    If you want to use handy parts of Foundation framework (like NSString or NSArray) for some of the underlying code, you could investigate GNUStep, which is available for Linux and Windows. I am not sure myself how well that would serve overall, though.
     
  15. jsmwoolf thread starter macrumors regular

    Joined:
    Aug 17, 2011
    #15
    But, wouldn't writing code in GNUStep require people to install additional software in order to execute Objective-C?
     
  16. mfram macrumors 65816

    Joined:
    Jan 23, 2010
    Location:
    San Diego, CA USA
    #16
    gcc does Objective-C and GNUstep represents the libraries and environment. But last I looked, GNUstep is like 10-15 years out of date WRT the state of the Mac.
     
  17. lloyddean macrumors 6502a

    Joined:
    May 10, 2009
    Location:
    Des Moines, WA
    #17
    jsmwoolf,

    You seems to be exploring something. Is it merely curiousity or is it for a commercial product?

    If it is for a commercial product could you give us an idea as to its nature?

    Your answers will help "us" steer you in a more useful direction.
     
  18. jsmwoolf thread starter macrumors regular

    Joined:
    Aug 17, 2011
    #18
    Just for curiosity, but the reason why I'm trying to find a GUI software that can be written in C/C++ is because the language can't deal with that kind of stuff and the syntax for Objective-C and Cocoa is very weird for my tastes even though I kinda understand it.

    The thing is, I don't exactly have an idea because I don't want to create something that is useless to me(For Example: A simple mathematic calculation). Yet, I don't want to create something that's too hard at my level. In addition, I would like to visually see my program rather than by a console completely. However, I use the console to check stuff.
     
  19. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #19
    Learn to love the console. If you're just starting out there's no reason to mess around with a GUI yet. When you DO get to a point that you are ready to tackle GUIs, i'd focus on a single platform to begin with. If you're working on a Mac, Objective-C/Cocoa is the way to go. If you're learning C or C++ right now, just stick with that and the command line. If the command line is too boring, I'd recommend starting with a language with an easy-to-use GUI library instead of one of these. Of course, the top recommendation on this forum for use on a Mac would be Objective-C and Cocoa, which you stated are distasteful to you.

    -Lee
     
  20. jsmwoolf thread starter macrumors regular

    Joined:
    Aug 17, 2011
    #20
    However, I'm willing to adapt to Objective-C as well. It's just weird to me for now. If I focus on it, I'll pretty much get over it. When I first tried Solidworks several years ago, I hated it because it worked in a 3D environment and my brain couldn't process it. However, after taking a course in it, I got used to it and actually loved it.
     
  21. cube macrumors G5

    Joined:
    May 10, 2004
    #21
    If you're not going to use Java, then Qt is the way to go.
     
  22. lloyddean macrumors 6502a

    Joined:
    May 10, 2009
    Location:
    Des Moines, WA
    #22
    If you value your customers, and unless you have a very specialized application an can get away with it, don't use anything but the native UI of your target platform.

    If you're doing programming that targets Windows, Mac and or Linux then don't use Qt or any other cross-platform GUI layer. Mac users will bad mouth it, Windows users will mostly be indifferent to it and Linux user are used to whatever they get. This is my experience across 30 some years of commercial development and yes that is outside the range of all three of todays most common OS's and GUI's.

    Refactor all code into application code and User Interface code. The application code will be cross-platform and the GUI will be custom per platform standards. Is this work? Yes but paying customers will pay more for something that "feels right", works well and integrates with other applications on their system of choice. If the user isn't happy with the look, feel and integration of your application with their system then you've wasted money developing it and you may as well not done anything for that platform in the first place.

    Respect the platform and your customers will appreciate your efforts.
     
  23. adildacoolset macrumors 65816

    Joined:
    Sep 5, 2011
    Location:
    Lusaka, Zambia(If you know where it is)
    #23
    I agree with cube. But if you wanna use Xcode, download the Qt framework and add it to Xcode and make a template
     

Share This Page