It seems that in Xcode 4 there is no longer a way to create an application that is not limited to the command line using C or C++. I would like to do so, however Glut seems to be one of the only frameworks available for mac that works with C++ and OpenGL, however gluts features are beginning to stop working on modern Operating Systems. Are there other alternatives that will allow me to use C++ or C for software development on a mac? It does not have to be limited to using xcode or opengl.
Yes, it's possible, but it may not be a very good idea. The real question is what problem are you trying to solve?
If you just don't like Obj-C, it should be straightforward to write a very thin shim that wraps the calls you care about in C++.
If you are trying to prove a point, you can actually make calls directly into the Obj-C runtime in plain C code. See this for example: using objc_msgSend to call a Objective C function with named arguments
If it's something else, please enlighten us so we can better answer your question.
QT is your best bet. It comes with a serious IDE and the libraries are written in a very good & intuitive C++.
QT can be found here: http://qt-project.org/downloads
If all you want is a window, an OpenGL context, and user interfacing, then go the SDL way. Completely written in C, cross platform, and almost object-oriented (most data types are structs, anyways). It's also very memory economic (its core DLL is less than 500KB in size and a windowless program uses less than 1MB of RAM on Linux), unlike the monster that is Qt.
I'd also recommend LazyFoo's tutorials to get started, since they indeed cover the learning from the perspective of a C++ programmer, not a C one.
Related
I am updating a C++ program written twenty years ago to run scientific experiments that involve the precise starting and stopping of sounds. The program also needs to be able to control playback volume, pause sounds or start them at a designated position, loop sounds a specified number of times, and control channel mapping.
The researchers hope to run the program on a modern Mac OS X, but I have never done any development on a Mac before. What is the simplest way to accomplish the above goals in C++ on a Mac?
CoreAudio seems way too complicated. NSSound seems to have all the features I want, but as far as I can tell it is only available in Objective-C? Is it possible to mix Objective-C with C++? Or should I be looking at using the QuickTime SDK?
Thanks for any help.
Yes, you can mix Objective-C and C++. It's a hybrid language called Objective-C++. If NSSound has all of the features you need, go for it; if not, CoreAudio is the way to go. It will be much more challenging to set up and integrate larger libraries such as QuickTime, OpenAL, or FMOD.
Yes, you can mix Objective-C and C++. Objective-C is just C with some stuff added on, and that same stuff can be layered on top of C++ instead to get Objective-C++ (in particular Objective-C++ doesn't have C features that are in Objective-C but not C++).
Using CoreAudio directly may be useful if you need very low latency.
Another option may be OpenAL, which is available as just another built-in framework, OpenAL.framework.
With few years of experience with Java I decided it's time to take the time and learn C++. I just compiled and run my first C++ with eclipse (of course) and would like to take it one step fw - I wish to build a GUI.
Question: what GUIs are available to C++, something that is an open-source and runs on Mac and eclipse.
Some have mentioned Qt, some wxWidgets.
A quick rundown on crossplatform gui toolkits that you could try:
Qt: Looks appropriately native on whichever platform you use it on. It has its own build system however, which doesn't always like to play nicely with others. If you want the "beginners" experience in making a GUI with Qt, I recommend Qt Creator. It's a standalone IDE built by the developers of Qt.
wxWidgets: While Qt looks native (it tries its best to emulate the look and feel of the OS you are running on). wxWidgets is native. That is, it uses the GUI elements provided by the operating system. Last I looked at wxWidgets the C++ library was falling behind as far as modern development practices go. You are possibly more likely to learn bad programming habits from this library.
gtkmm: This is from the same guys who make the GIMP and Gnome, which as a MacOS user probably doesn't mean a lot to you. They don't try nearly as hard to fit in as wxWidgets and Qt. However, they probably have the most modern C++ library. They have done a lot of work to use modern C++ development practices. This can be helpful for a new programmer, as you are less likely to learn bad habits from them. On the downside, you'll get thrust into the land of templates and function pointers and such.
Those are the big ones with the most momentum behind them. There are countless others to also consider.
Use Qt
http://qt.nokia.com/products/
http://qt.nokia.com/products/eclipse-integration/
I'd recommend Qt which is open source, has an easy-to-use API with GUI designer, and can be used on many operating systems (Windows, Mac, Linux..) and looks native on whatever it's used on.
You might want to take a look at wxWidgets or Qt:
http://www.wxwidgets.org
http://qt.nokia.com/products/
More generally, see here:
http://en.wikipedia.org/wiki/List_of_widget_toolkits#Based_on_C_or_C.2B.2B_.28including_bindings_to_other_languages.29
I've personally used wxWidgets and found it to be quite good, if you're after a recommendation.
I’m a native C++ programmer never knew anything about low level C, due to some circumstances I had to use C extensively. The outcome was me catching on a lot of C habits.
Know I’m trying to develop some Computer Vision project using OpenCV, TBB, OpenCL and OpenGL.
The thing is OpenCL is native C, so is TBB I guess not 100% sure about the TBB. As everybody knows C++ is an industrial Language and so Developing in it is a blast(at least for me) but after doing the main Which language should I use research? I’m know more concerned with C/C++ Code MIXING….
So my question is this Should I Develop the whole thing in C (Hard to maintain, expand and develop with) or should I stay with C++. And if I’m staying with C++ can someone plz direct me to a good way, strategy(Book, Tutorial) of mixing C/C++.
Thanks in advance.....
All the technologies you mention have C++ APIs. So if you are already comfortable using that, by all means do so. There does not need to be any mixing of C and C++ in one file, at all.
Only the OpenCL kernels are written in plain (OpenCL-) C. You do not mix the code, but you may have to pass data from your C++ code to your OpenCL kernel. Since you mention you now know both, that should not be a problem.
This C++ faq lite entry should be helpful. Mixing C and CPP
I'm considering learning Objective-C and Cocoa, mostly in order to use Apple's tools and GUIs.
However, I'd also like to do some graphics programming; OpenFrameworks and Cinder are two libraries which catch my eye, but then we're in C++ land.
I come from a Java/Swing/Processing background... don't know much about the C family. How effectively can you call C and C++ libraries, like Cinder and OF, from native Cocoa?
And, bonus points: would a solution like this work on an iPhone or iPad?
In short, C++ is just fine for OS X and iOS programs, and plays with Objective-C quite nicely.
In more detail:
However, I'd also like to do some graphics programming; OpenFrameworks and Cinder are two libraries which catch my eye, but then we're in C++ land.
I won't speak for those libraries directly.
To answer your question in more general terms: C++ is just fine in your app, since C, C++, ObjC, and ObjC++ are first class development languages for iOS apps.
I come from a Java/Swing/Processing background... don't know much about the C family. How effectively can you call C and C++ libraries, like Cinder and OF, from native Cocoa?
Objective-C++ allows you to use C, C++, and Objective-C all in the same translation. Feel free to use/combine C++, C, or ObjC where needed. The compile times will increase, and there are some restrictions* if you take this route. Otherwise, support is very good. Even Apple uses a good amount of C++ in their apps/libs.
And, bonus points: would a solution like this work on an iPhone or iPad?
Definitely. c++11 support for iOS and OS X is currently a bit behind. However, the clang team's been adding support for it very very quickly. There will likely be some bumps if you want the latest features, so I'd say hold back on bleeding edge C++ and compiler features if your project depends on it. Of course, it does not hurt to sample your program using the latest clang features with each release in order to determine how well it works with your programs.
Update: At this point (Nov 8, 2011) clang can handle nearly all of the C++ 2003 code I throw at it. Code speed and size does vary compared to GCC+LLVM. I would not want to drop either at this point, but both compilers work well for me with C++ 2003, and Apple's GCC will not support c++11, so it's a good time to start testing clang if you want c++11 features in the near future.
C++ is ideal (IMO) for general performance critical development on iOS, as long as your team knows how to use it.
Mixing C, ObjC and C++ is very powerful if you use the right features of each language for the right reasons, and good compatibility exists. This reaches back years from OS X (although the compiler was GCC at the time).
*restrictions: these are reasonable restrictions - all the features you need exist, but there are some things that people may expect which are not possible. the most common is likely the inability to derive types of different object models. that is, you cannot reasonably not create a c++ type from an objc type, but you can freely declare ivars of multiple types in either object type.
It is possible to use both OpenFrameworks and Cinder in iOS applications (see this related SO question: OpenGL ES, OpenFrameworks, Cinder and IOS creative development), though Apple "prefers" developers to use OpenGL.
As of now you can use Cinder from within a typical Cocoa project via the new CocoaCinderGL wrapper. It lets you add several NSCustomView's to your application, each one running an independent "instance" of Cinder. And obviously you can connect as many NSButtons, NSSliders as you like to those instances. Hope that helps!
I wrote a small program with Boost in c++. It works fine and so I want to give it a graphical interface so that it is easier to use.
In order to do so, I am looking for small cross-platform framework which provides native look and feel. Windows and Linux support would be enough, currently i do not need os x...
I used wxWidgets for some other project, but it was a pain to set everything up and ship this big library with the software.
But I was really amazed by the use of real native controls.
In order to keep the program small I also tried fltk, but it has an awful look.
I just need an simple framework without network support or other gimmicks.
So my question: Is there any framework out there which fits all the requirements? Or if not, which frameworks fits at least some of these needs?
Thanks in advance!
When it has the word "framework" in its name it's almost never small.
Anyway, graphical frameworks/libraries tend to be big, cause they need to handle a lot of stuff.
Qt is probably the best straightforward library for cross-platform GUI, but it definitely doesn't constitute a "small framework". On the other hand, on Linux systems, Qt will be most likely already installed. Plus it definitely pays for its size.
wxwidgets is fairly small as far as gui toolkits go.
And it's cross platform
http://www.wxwidgets.org/
You have mentioned it, but as far as cross platform toolkits go it's one of the smallest I've seen.
The only other suggestion I have is that you could wrap your code up into a C library and link that into another language. e.g. Use .NET on windows and mono for linux or even a java based app (although they don't always look very native to the platform). Then use your library from there.
Ultimate++ might contain what you need. (Although they make it sound in the FAQ as if their library is really big, it doesn't seem that bad to me.)
don't forget to check juce as well
Qt works amazingly, but is not very small. I've found there is a genuine lack of "small" cross-platform GUIs. You either might try to just abstract your GUI with #ifdefs all over the place, or use Qt/wx.
If you want it to be small, just write the GUI twice -- once in MFC and then in X. Your GUI sounds simple enough. Build up your own small abstraction that is just what you need.
There is a long list of both active and dead cross-platform C++ UI libraries here: https://philippegroarke.com/posts/2018/c++_ui_solutions/
Some of them are small and have a native look.
Like others mentioned you cannot mix the "cross platform" and small in size in the same sentence.
More work, smaller in size:
One solution I can suggest is to use native python binding for the UI portion. Since you are already using boost, it should be fairly trivial to have Boost.Python communicate between C++ space and python space. You already have python on Linux and its a 20-40MB package on Windows (can't remember how big the latest release is). But here you will have to use win32 binding on windows and gtk/qt bindings on linux, so more work. Nah, too much work to maintain, scratch this.
Moderate work, smaller in size but with non-native controls:
You can try to get clutter or freeglut to get your UI work done but I personally haven't used them so I don't know if they provide full native looks for your apps. But they are small in size compared to wx or qt.
Less work, bigger in size:
Use WxWidgets if you are already comfortable with it, otherwise I recommend Qt.
You can also have a look at some of the other offerings: http://en.wikipedia.org/wiki/List_of_widget_toolkits
Clutter: http://www.clutter-project.org/about
FreeGLUT: http://freeglut.sourceforge.net
ever heard of QT ???
http://qt.nokia.com/products/
i think it should fits all your your needs