Cross-platform coding: How to get started?

Discussion in 'Mac Programming' started by zickzack, Jun 13, 2010.

  1. zickzack macrumors newbie

    Joined:
    Jun 13, 2010
    #1
    Hello forum,
    I'd like to build an application in C++ that natively runs on Windows and Mac OS X, but this seems to be a daunting task. Which frameworks, libraries and IDEs would you recommend?
     
  2. GorillaPaws macrumors 6502a

    GorillaPaws

    Joined:
    Oct 26, 2003
    Location:
    Richmond, VA
    #2
    You might want to build a small mac-only C++ project first before adding to the complexity by making it cross platform.
     
  3. breatheasy macrumors member

    Joined:
    Mar 9, 2010
  4. lloyddean macrumors 6502a

    Joined:
    May 10, 2009
    Location:
    Des Moines, WA
    #4
    Could you tell us more about this application you like to build?
     
  5. zickzack thread starter macrumors newbie

    Joined:
    Jun 13, 2010
    #5
    Ok, but which tools would you recommend for this purpose? For a Mac-only program I would definitely use Xcode and Objective-C, but for a multiplatform app I must use a GUI framework like wxWidgets and maybe I would also be better off with Eclipse than Xcode...
     
  6. Thomas Harte macrumors 6502

    Joined:
    Nov 30, 2005
    #6
    Based on my experience of VLC, OpenOffice, etc, I'd vote that you stick firmly with model-view-controller and plan to rewrite the interface afresh for each platform. All of Linux, Windows and the Mac are able to call out to C++ code for the back end, even if you're in .NET on the Windows side.
     
  7. zickzack thread starter macrumors newbie

    Joined:
    Jun 13, 2010
    #7
    Thank you. Does C++ has the same mightiness as Obj-C or am I limited in any way?

    The application should just be some kind of test, because I am curious about this cross-platform topic.
     
  8. Hansr macrumors 6502a

    Joined:
    Apr 1, 2007
    #8
    C++ is just a versatile as Obj-C but doesn't give you as many build in libraries and APIs and in many instances you will need to write a lot of the functionality you're used to yourself. But having said that provided that in addiiton to STL you also use Qt, Boost, C++0x etc you'll have a lot of extras that are useful and cross platform friendly.

    Qt has excellent gui building elements that will work across different OSes but I still prefer using native GUI building elements on each side (Mac: Cocoa, Win: .net+extra libs)
     
  9. mslide macrumors 6502a

    Joined:
    Sep 17, 2007
    #9
    Use Qt and C++. It's a really nice framework that probably has everything you'd want. It does a really good job in making programs that look like they were programmed using their native platform's frameworks. It's a lot more than a gui framework as well. It's got a lot of the things you'd find in the STL or Boost libraries. Qt's the best way to go IMO. Most of my Qt programs don't have a single platform dependent line of code although sometimes that's necessary.

    It comes with a build system that works well on all platforms but another option is cmake. What's nice about cmake is that from a common set of script files, that you create, you can create unix Makefiles, Visual Studio project files or XCode project files. I think Qt's 'qmake' has a similar feature but I've never tried it.
     
  10. zickzack thread starter macrumors newbie

    Joined:
    Jun 13, 2010
    #10
    It seems to be quite complicated, but if it wasn't there wouldn't be a a great market for Adobe Air and Java programs out there. :)

    I don't have experience with Xcode, but with Eclipse and Visual Studio. Is it possible to use one IDE for Mac OS X and Windows programming? This might not be optimal, but less confusing, because the workflow remains the same.
     
  11. GorillaPaws macrumors 6502a

    GorillaPaws

    Joined:
    Oct 26, 2003
    Location:
    Richmond, VA
    #11
    What's an OSX app written with Qt that looks as good as a Cocoa app? As Thomas Harte has stated, the "most correct" way to do this is to use a MVC paradigm.
     
  12. lloyddean macrumors 6502a

    Joined:
    May 10, 2009
    Location:
    Des Moines, WA
    #12
    You're being given premature recommendations. So, again I ask (roughly) describe this cross-platform program you'd like to build.
     
  13. mslide macrumors 6502a

    Joined:
    Sep 17, 2007
    #13
    Qt can be compiled to use Cocoa. It uses the native platform's UI widgets. Since Qt always needs to be the lowest common denominator between the major platforms, it obviously will not be able to take advantage of features unique to one particular platform but I think that is a small price to pay. Then again, I'm not an OSX purist.

    The 'most correct' way is the one that meets all of the OP's objectives best. The MVC model certainly has its advantages but it can also greatly increase development time, unless he/she is already familiar with Windows/OSX APIs. For me, time is money and the time savings that Qt offers wins almost every time.
     
  14. GorillaPaws macrumors 6502a

    GorillaPaws

    Joined:
    Oct 26, 2003
    Location:
    Richmond, VA
    #14
    So what app would you hold up to be an example of a really terrific QT app that looks and feels native, as you stated earlier?

    To me, the "most correct" way to do something is how you would do it if you had unlimited resources, and ideal circumstances to make the best possible software. Obviously reality prevents us from getting there, but I wouldn't consider the version that requires you to compromise the end result because of real-life constraints to be most correct. But that's just my opinion.
     
  15. softwareguy256 macrumors regular

    Joined:
    Jun 5, 2010
    #15
    I am doing exactly this, in fact most of my iPhone app most was written in MSVC 2005. The trick is to keep the logic and algorithms in C++ and to write the OS specific code wrapped in abstract interfaces. It's not as much work as you think if you scope the problem correctly. The key is to be flexible enough but not so much that you end up creating a solution that is looking for the problem.

    I personally will never go down any widget or Java route. It makes your app look like crap and it does not integrate well with things like Windows Aero and custom themes. I've seen enough apps written with them that I don't want to be confined to their ways of doing things, think Apple's reasonings for not supporting Flash.

    Show us some of your QT apps then.
     
  16. zickzack thread starter macrumors newbie

    Joined:
    Jun 13, 2010
    #16
    Thanks to all :)

    @lloyddean

    I just want to make a kind of demo application to apply for a job. However, it's kind of difficult to find something that's useful and not too complex. Any ideas?
     
  17. lloyddean macrumors 6502a

    Joined:
    May 10, 2009
    Location:
    Des Moines, WA
    #17
    Not to play twenty questions but do you have a particular type of application, or even company, in mind. Your goal affects my answer!
     
  18. zickzack thread starter macrumors newbie

    Joined:
    Jun 13, 2010
    #18
    I thought about making some kind of tool, maybe a converter, code generator
    or something like that. The main thing is that I do something that makes sense and has a certain presentable value.
    Hope my answer is not too vague...

    What I don't want to do is game programming (too artistic, too elitist).
     
  19. gnasher729 macrumors P6

    gnasher729

    Joined:
    Nov 25, 2005
    #19
    Libraries: Standard C++ Library (STL). Write as much code as possible in a portable way, which would imply C++. Put everything that you want to be done differently on Windows and MacOS X into separate classes that will have the same name and interface in both versions, but completely different code. In the MacOS X variant, that code will likely connect to Cocoa code. Important: Find someone with experience who can guide towards the right level of abstraction and the right boundary between portable and non-portable code.
     
  20. Les Kern macrumors 68040

    Les Kern

    Joined:
    Apr 26, 2002
    Location:
    Alabama
    #20
    Check out Real Studio. Plenty of sample builds to look at, great community.
    www.realsoftware.com
     
  21. PatrickCocoa macrumors 6502a

    Joined:
    Dec 2, 2008
    #21
    I'm actually a nice guy . . .

    . . . and I'm not trying to be obnoxious, but if you're putting together a portfolio to demonstrate your programing skills, you should focus on things you're good at and know something about.
     
  22. lloyddean macrumors 6502a

    Joined:
    May 10, 2009
    Location:
    Des Moines, WA
    #22
    Apologies, I'm sorry to say I do find your response kind of vague so this 'elitist' programmer is unable to provide any useful suggestions.
     
  23. Detrius macrumors 68000

    Joined:
    Sep 10, 2008
    Location:
    Asheville, NC
    #23

    Soooo... do you even need a GUI?

    There's much more to game programming than art. Some people design the art for the game, and then someone else makes everything work correctly. Saying you don't want to do something because it's "elitist" actually sounds elitist. :cool:
     

Share This Page