GUI Programming C++ for Mac OS X Lion - c++

I'm probably going to get abuse for this question but here goes. Oh but before you tear into me and tell to crawl back under a rock etc. I have looked high and low and nothing has helped me so far either the software libs are out of date and for some reason wont work on lion.
Ok other than Qt is there any other lightweight opensource GUI library for C++ on mac? I have tried this wxWidgets doesn't work for some reason. Apple don't seem to offer that carbon crap anymore or can I use openGL to create GUI's? I just want a simple nicely documented GUI lib without having to switch to windows to develop. or will I have to spend some money on one or resort to Qt.
Hope someone can help and thanks!

Why not use Cocoa (the native way to develop OSX GUIs) in the first place? You must use the Objective-C calls to create windows for example, but you can mix this code with C++ code in the same file - this is then called Objective-C++ and it is supported by clang and the gcc.
To build completely native-looking OSX Applications, you need Cocoa. Every other toolkit that can create those native GUIs calls Cocoa (at least to my knowledge).
Just as a pointer: have you tried SDL?

FLTK is simple and very stable GUI library. Runs on Windows, OS X and Linux.
Non-native look though.
Here is a screenshot of an app I built with it a few years ago, and that still runs great on Lion.

I'd take a look at both GLUT and GLUI as simple extensions to OpenGL that provide basic widgets. They can be used together to some degree, but I personally have run into a couple issues in that department. Either one in isolation is pretty simple to use if you're familiar with OpenGL though.
EDIT: Also, X11 can run in OS X, although I'm not familiar enough with the system to know how to get started with that.

Related

is GTK 3.x a real cross-platform solution?

I have tasted both Qt 4.x/5.x and GTKmm 3.x and I really like GTKmm over Qt.
Now I have just discovered that GTKmm 3.x doesn't offer a Windows porting, they also do not offer a Mac porting, basically I can't find nothing but libraries/sources/binaries for Linux.
Apparently the Windows support ( I'm not sure about the situation for the Mac OS stuff ) was dropped in the 2.x era and it's still not-existing today.
I have planned to use GTK 3.x for specific reasons, especially for some new features introduced by the 3.x branch, so using GTK 2.x is an option off the table.
Now I ask: there is something new for the Windows and/or Mac support for GTK 3.x ? There is something ? even experimental projects ?
No it isn't - at least when you want to be on the safe side for the future. The MacOSX and GTK ports are less then perfect and completely voluntarily which means by a program of this complexity and size they are not not active developed. And nobody cares that old features are implemented before new are added.
Almost 2 years since GTK3 released and there is still no official Windows binary distribution. And on one of the GNOME conferences there was an open discussion if GTK4 should be made Linux only. Well i guess they mean Linux/BSD - but Wayland is pure Linux at the moment and BSD do have a lack of developer for Desktop stuff.
This should be enough to scare any person with a serious program which requires real world investment away.
Also i strongly belive that cross platform GUI toolkits are a thing from the past. Abstract the GUI of your app and develop for every platform. With the success of the AppStores you will be forced more and more to use the native platform style. Your app will already be rejected by Apples AppStore if it looks to different. Windows is now enforcing WinRT. Be prepared that this will just be more important in the future.
So the way to go is WxWidgets which uses native widget sets. Skip GTK
2018-12-18 Update:
GTK+ 3 on Windows has been supported through MSYS2 for years.
Old answer:
GTK for Windows is currently provided "as-is". What it means, basically, is that there are no GTK maintainer that use Windows, and those using Linux have enough work maintaining the Linux builds.
This means that any contribution for GTK 3 on Windows is welcome, some people are using it, but that's not ready for the masses because nobody steps up to do the work, which won't be done by magic overnight. So it's usable, but don't expect reactive maintenance.
As for the build, there's a french dude providing an (unofficial) GTK 3 installer for Windows.
As of right now, no.
Like Frédéric Hamidi said, see Where can I download precompiled GTK+ 3 binaries or windows installer? for more info.
GTK on Mac has worked well for a long time and continues to work into the 3.x series:
https://live.gnome.org/GTK%2B/OSX/Building
You can also install GTK 3.x using MacPorts, but I don't know how well that works.

Compiling/Running C++ code on iPhone

I have recently created an Asteroids game/app for one of my CS classes with openGL, GLU and C++ for Linux. The teacher told me that if I get it to run on the iPhone he would give me extra credit. I have been looking around and I think I have to develop/port it to Objective C using the iPhone Development Kit. My questions are:
Would this be easy to port?
Can I install the Development Kit on Windows, or Linux (I do not have a Mac).
Is there an alternative way (shortcut) to maybe emulate Linux binaries on the iPhone?
I have not tried anything yet, because I would like to know first what you guys think. You do not have to tell me exactly what to do, but I would highly appreciate if you would point me in the right direction.
Thanks.
Well, if you don't want to port your program into another language. You CAN use SDL2, it seems pretty stable and it works on iOS (iPhone/iPad/iPod Touch). All you would have to do is change your code and then play around with the controls. You'll have to clone the Mercurial repo from http://hg.libsdl.org/. It will come with a README.iOS file, in which describes how the port works and some other details. I am not sure if it has multi-touch support yet, I have not tested it.
Also, you can use immediate mode on the iPhone, you just can't use OpenGL ES 2 if you do that. All you have to do is make a context for OpenGL ES 1.1.
And you WILL need a Mac, or perhaps you could get a Hackintosh to compile your code and then run it with a jailbroken iPod/iPhone/iPad.
NOTE:
I believe I have heard of some people compiling their code on a Hackintosh and then submitting it to the app store from a Mac within an Apple store.

GUI in C++ for OS X Mountain Lion

I need to be able to launch a basic GUI from an application written in C++ on Mountain Lion. The obvious ways this would normally be accomplished is through either a cross-platform library like gtk or qt or by launching the c++ code from an objective-c based application. Each has its problem in this case. The application I'm writing uses a class library to connect to a robot. For the application to use the functionality, it must be compiled using the g++ compiler from terminal. The code was never designed to run on anything past Snow Leopard, so it's quite touchy when it comes to compiling and linking. This would seem to preclude my ability to start the C++ code from objective-c written using the xcode ide unless xcode includes compile options that I'm not aware of, at which point other platforms like gtk or qt seem viable. The problem with those is that I haven't been able to get a single one to even compile on Mountain Lion, let along been able to write an application using one. Is this a problem with Mountain Lion/lack of updates? And are there other options for creating the GUI? Maybe a GUI library compatible with Mountain Lion or a way to launch a cocoa-based GUI from the C++ code? It doesn't need to be complex - just a window with some lines drawn in it.
Thanks in advance!

Programming in C++ with Xcode 4

I want to use Xcode as my major complier for C++. However, I'm having a hard time starting programming. Which kind of project and target should I select if I want to write some applications with user interface?
I've been coding with Xcode for one semester but all the projects were half-done the time I saw them, so I really don't know how to start by myself. I tried the Command Line target but it did not seem to generate an application.
Sorry for asking these naive questions. Thanks for any help!
You can start with a barebones project by going to New -> New Project -> Application (under Mac OS X) -> Command Line Tool. This will give you a basic main() function that you can enter code into. This is what I use alot of the time for algorithm practice.
If you want your app to use a GUI framework, you can either choose the template that #sblom suggested and make a Cocoa Application (here is a good guide to get you started), or you could use a C++ framework such as wxWidgets or Qt (usually used with it's own IDE, Qt Creator).
Note that while Cocoa is in Objective C, you could just as well program in C++ for the core functionality of your app, just make sure the implementation files have a .mm suffix.
You'll need to use Mac OS X -> Application -> Cocoa Application. Unfortunately, it won't exactly be in plain ol' C++, although you can use C++. You'll have to use Objective-C to make actual calls into the Cocoa Framework (well, there are ways to make the calls using straight C/C++, but that's really cumbersome.)
I will highly recommend to use QT but not WX.
We use WX for years in our Valentina Studio application. And we going switch to QT asap. Reasons are that WX on MAC has weak progress. Troubles with Cocoa support. QT looks much more better choice ...

Cross-Platform Objective-C / C++ Development

I work in a team of developers, one of us works specifically under Windows, and I work primarily in Mac OS X. We're wanting to develop C-based applications either in C++ or Objective-C however I'm not really knowledgeable in how to go about a cross-platform development project.
Is it viable to work in C++ using Mac OS X? Obviously they're geared towards Objective-C but is there just as much support for C++. What about cross-platform development in these languages? I'd use something like boost and some kind of UI library.
Has anyone got any experience in developing for multiple platforms yet allow applications to run natively without the need for a VM?
EDIT: There's a lot of answers I want to mark as correct now. It seems like Qt is the way to go and develop it in C++. Chances are this will be for *nix, OS X and Windows so that would be the best option for us personally. If I can avoid writing Objective-C so the team sticks to C++ then all the better. If I have to write the GUI in Objective-C and mix and match then that's not too much bother either.
I work for a software company that produces software for Mac OS X and Windows using C++, MFC, and Objective-C.
Yes, it is definitely possible.
You probably will be best served if you develop the "core" of the application in C++. In a MVC application, the C++ part would be the model, and possibly the controllers. For the code that interfaces to the GUI and other OS-specific interfaces, you should use the native APIs: Objective-C on Mac OS X and C# on Windows XP.
The good thing about the Mac is that you can compile C++ and Objective-C together. You can even have Objective-C++ where C++ and Objective-C are compiled in the same compilation unit. Unfortunately you cannot do this with C# (there is something called Managed C++ which is a different beast).
I would avoid cross-platform frameworks such as Qt and wxWidgets. They both allow you to develop cross-platform applications, but the look and feel of such applications is sub-par. I have more familiarity with wxWidgets though, its design is heavily geared towards the Windows MFC paradigm of application design.
Edit May 14, 2009, 9:44 AM EST: If Qt now allows true look and feel of the native platform, it could be a good option. I haven't looked at the latest offering so you may want to look at that framework before designing your own. That decision should be made after examining the results of the applications and how comfortable you are with the design paradigms that Qt requires.
You could look at Qt. I've used it successfully on Windows, Linux and Mac OSX projects.
what I use, is have a common library written in C or C++ with all the core functionality of your application.
Let's say you are building a solitaire game. So you will have core classes in a pure C++ (mostly platform independent) library.
CoreSolitaire
Then, you will have separate UI projects, one for each platform you want to deploy your solitaire on:
iSolitaire (Objective-C, MultiTouch Cocoa Based for iPhoneOS)
MacSolitaire (Objective-C, Cocoa Based for Mac OS X)
WinSolitaire (C++, Win32 or C# Based for Windows plaforms)
GSolitaire (C++, GNome/GTK based for linux/unix)
It's more work, but, in my opinion, the resulting product is definitely better than one you could get by using a platform independent widget set like QT or wxWidgets.
Having said this, if you are going to deploy your product internally in a company where you have full control of the deployment environment, and you don't care that much about how the resulting product will behave on different platforms, you could definitely use a common API for everything (QT, wxWidgets, or any other you might encounter).
Is it viable to work in C++ using Mac OS X? Obviously they're geared towards Objective-C but is there just as much support for C++.
Yes, there is.
You can do pretty much anything you want with C++ in OS X --anything that you could do with C++ on Linux, for example. There is support for the gcc's C++ compiler, c++ libraries, et all. Xcode provides support for working with C++.
You can even mix c++ with objective-C with Objective-C++ (Note, however, that this is not portable for GUI work).
What about cross-platform development in these languages? I'd use something like boost and some kind of UI library.
I believe that your best bet is QT.
It is a stable C++ library that is cross-platform (Windows, OSX, Linux and more), has been around for over a decade, is well supported, with many commercial apps written in it (Skype, Adobe Photoshop Album) and a ton of open source stuff written with it (the KDE desktop for starters). Besides GUI stuff it provides a whole lot more (container classes, xml, database connectivity, etc).
You can develop both Open Source and proprietary (closed source) apps for free with the latest QT, and the library was recently bought by NOKIA, a huge multinational, so it isn't going away any time soon.
Besides the library, QT also comes with an IDE and a Visual Forms Designer (all for free).
Other cross-platform GUI libraries for C++ also exist for OS X (wxWidgets, gtkmm, et al).
Has anyone got any experience in
developing for multiple platforms yet
allow applications to run natively
without the need for a VM?
Slightly. Make sure that you wrap around all the platform specific code.
That way you're main application or library doesn't need to reference the platform specific code. That should make it alot easier when porting to another platform.