Programming in C++ with Xcode 4 - c++

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 ...

Related

c++ gui window cross platform

I would like to make c++ that will work both on Linux and windows as I understand if I use the win32 template in visual studio then it will only work on windows is there something built into c++ like java's jframe that I can use. Also I would like to use any external library at this time.
Here are some cross platform alternatives QT, wxWidgets, Ultimate++. I have used QT, it is intuitive with a huge collection of tools to use in your code. The others are also popular but I have never used them.
I make used of wxWidgets due to it's cross platform and even cross architecture, native look on the OS where it appear. Binary application yields by wxWidgets is small enough thus make it possible to linking statically as portable application. Qt produce huge binary if linked statically (and may be violate qt licensing scheme).
Another reason are licensing flexibly, well documentation and supported by huge community arround the world. wx is considered as mature framework since it first release about 20yrs ago. It's use standard C++ syntax and preprocessor that will make you easily switch from plain C or C++. Complete library are available ranging from appeal window GUI, string, network, stream, webview, xml, and wx is playing very well with 3rd party library as such database SOCI, Asio, etc ....
You may try start to code with wxWidgets easily using Eclipse-IDE and wxFormBuilder as GUI designer. Plese check my experience for ease setup it's IDE+Toolchain. This wx installer can be used do develop, test and run wx application on Linux desktop, and then deploy the binary on Raspberry Pi is available for another board target beside Linux x86_64.
http://yasriady.blogspot.co.id/2016/01/raspberry-pi-toolchain.html
There is a cross-platform application & UI development framework called Qt. I think it meets your requirements. Click here for more info.
There is a long list of both active and dead cross-platform C++ UI libraries here: https://philippegroarke.com/posts/2018/c++_ui_solutions/

Use Qt codes in C++

I have some codes in Qt Creator that work properly. I need to use this codes but in win32 application in .net framework. Does anyone have any idea how can I do this? I am totally new to Qt and do not know how to use this useful codes in c++ project?
I appreciate any help in advance
I think I could not get my message across. Qt is c++ but It has some differences with the native c++ app that we use in .net framework. so I can't just copy all the codes in my project to run it properly. Can we make a dll or library to use this qt code in .net or not? and how can I do this?
I really need help. Thank you so much
For almost all cases, you do not want to mix .net and Qt in same application. It's less work to just take the logic and rewrite it for .net (managed C++ or C#).
Next best option might be to keep the parts separate and have them communicate through some IPC mechanism.
This is, because any non-trivial Qt code depends on it's own event loop, so getting the existing Qt code play nice with other event loop is always a hassle, and trying to get it play nicely when actual application is managed .net code... No, just no, unless you have a very compelling reason, are expert on both Qt and .net, and have extra time to make it work right.
I'm not sure if you don't know how to download and install Qt or how to create a Qt project in Visual Studio IDE. Try this installation guide.
Do you want to link the Qt library to your win32 c++ app? I think you should build the qt source code first with your win32 compiler. I think you could include the qt header and link the library as normal win32 library to your application after that.

C++ app for IPAD with C++Lucene library

I am planning to build an app in C++ for ipad. I have never build any app for ios. I want to know whether is it possible to write a C++ app using Lucene library in ipad. Can i write the code in visual c++ and compile it in xcode. Can i use the same code to work in mac os as well? I really wanted to build the app in Java so it works every where but unfortunately I pad doesnt support java.
Please provide me some good suggestions to build this app.
Thank you.
No. You can't build for iPad in Visual Studio.
You can include C++ in "Objective-C++" files, named .mm, but you will have to learn a minimum of Objective-C in which to include your C++ code.
As for using the same code for mac, it depends on how well you separate your logic from your display code - you can reuse some code, but you can't simply hit "build for Mac" and have iPad apps magically run on the Mac. You'll have to, at the very least, build a totally separate interface.
Building apps for iOS, etc requires some simple steps :
Buy a Mac
Learn some Objective-C
There is no other way around that makes sense.

GUI Programming C++ for Mac OS X Lion

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.

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.