14

I have till now mainly concentrated on web programming thus far and now want to enter application programming space. I use a mac, and wanted to know what sort of compilers, IDEs etc people generally use for c++ dev.

extremely n00b One more thing immensely bothering me was the fact that c++ compilers generally output .exe which can't be used on macs. I need to understand basic OOP programming fundamentals and thought c++ would be the best choice. Please suggest something.

gsamaras
  • 71,951
  • 46
  • 188
  • 305
amit
  • 10,133
  • 22
  • 72
  • 121
  • For mac terminal c++11 see here: http://stackoverflow.com/questions/14228856/how-to-compile-c-with-c11-support-in-mac-terminal debugger is lldb – JayS Sep 03 '16 at 21:01

9 Answers9

10

Compiling C++ on a certain operating system (OS) will create an executable file for that OS. You are not limited to only a .exe binary file.

The first step to start creating your first C++ application is to install Xcode. This development program is not installed by default with Mac OS X. You must insert one of the DVDs that came with your computer and install it. After, start Xcode and click on File and then New Project. Once that is done, select Command Line Tool and make sure that C++ stdc++ is the selected type. Before I forget to write this, Xcode's compiler for C++ is gcc. If you need some help to start off you always visits some sites or buy (or rent) some books.

One thing to note is that Apple's main programming language is Objective-C which is different from C/C++. While both of these languages have common features, it might be easier to start with Objective-C. It is possible to do some OOP with Objective-C and it will be easier with it. On the other hand, it is possible to do more complex OOP with C++ than with Objective-C.

If you ever wish to learn the basics of the Cocoa Framework (which is a set of libraries and tools to help you create a window), I suggest you learn how to program (some Objective-C or C++ could be nice) and buy the book Cocoa Programming for Mac OS X from Aaron Hillegass.

Partial
  • 9,529
  • 12
  • 42
  • 57
3

If your question really is: can I use C++ to develop Mac applications, then the answer is yes, but for true native Mac applications you probably want to invest in learning Objective-C and the Cocoa frameworks.

Stefan Arentz
  • 34,311
  • 8
  • 67
  • 88
2

A c++ compiler will output object code that should be native to the platform the compiler is built for. So on a mac it will output executable programs that will work on a mac, not windows executables.

XCode is a well regarded mac IDE that you can use for C++ development.

Java may be an easier choice for OOP as it avoids many pitfalls that can catch out novices. Another OOP alternative is Objective-C which is a good choice for mac development.

sfg
  • 489
  • 4
  • 7
  • -1: It would be easier to do Objective-C than Java in a Mac OS environment and if the OP wants to learn C++ later on. – Partial Feb 28 '10 at 19:46
1

You also can use QT Creator which is a really nice IDE :)

Joan P.S
  • 1,553
  • 1
  • 16
  • 42
  • Qt is a hugely overpriced system with the most ridiculous ideas about what a single independent developer can afford. It's only good for free projects unless you have money to burn. The subscription model is toxic from word one. Sub ends, you can't even rebuild your app to fix bugs. The qt people are out of their minds. Biggest mistake I ever made was to develop in Qt. – fyngyrz Sep 13 '16 at 18:04
  • @fyngyrz You seem to have a few misconceptions about the QT licensing system. If you link dynamically, QT is free to use even commercially – IceFire Feb 26 '17 at 16:16
  • @icefire That is not at all clear to me, and I have read the licensing verbiage. Can you cite a definitive reference for this? – fyngyrz Feb 27 '17 at 12:24
  • @fyngyrz Just google a bit for it and you find many threads like http://stackoverflow.com/questions/11994053/can-i-use-qt-lgpl-license-and-sell-my-application-without-any-kind-of-restrictio, http://www.qtcentre.org/threads/50552-It-is-free-for-commercial-use-(Question-about-licence) or others – IceFire Feb 27 '17 at 12:29
  • @icefire Threads on SO are not definitive legal commitments / positions from the QT rights-owners. As I said, I have read the actual licensing materials from QT, and it is not at all clear to me from those that I can create a commercial application without owing them money, from what those materials say. If there are actual QT licensing materials that clearly state what you are claiming here, I would love to see them. Google has turned up no such thing so far, which could simply be inadequate searching on my part of course. – fyngyrz Feb 27 '17 at 13:59
  • @fyngyrz Those are implications from people who seem to understand the legal terms exactly. But the license terms are not written with terms like "dynamic link library", so you can either trust the interpretation behind the links or ask a lawyer yourself. I have not found a public lawyer statement towards the QT license – IceFire Feb 27 '17 at 17:48
  • 1
    @icefyre Here's the problem: As a non-lawyer, _and_ a very small developer these days, I can't base a business case on random people's interpretations, _or_ afford engaging a lawyer. QT's actual licensing materials seem quite clear in that they want a lot of money if YOU get money and in that they won't let you update such code w/o continuous payments, but have made an exception for _free_ software. It seems... unlikely... to me that they want a lot of money, but are willing to get $0, based only on how you link your code. And I'm not finding this stated clearly anywhere but by non-QT people. – fyngyrz Feb 27 '17 at 18:19
0

Just use xcode / gcc to create and compile C++ applications on your mac. Native Mac applications are most commonly coded in objective-C, but since the mac is a variant of bsd, using gcc tools to create a c++ executable is also common.

edit: to clarify: - xcode is the free Mac IDE that comes on the install disk - gcc is the open source compiler. it is part of Xcode.

D.C.
  • 15,340
  • 19
  • 71
  • 102
0

If you are using a Mac Xcode is the way to go, there are of cause others out there, like Net Beans and Eclipse

Jesper Fyhr Knudsen
  • 7,802
  • 2
  • 35
  • 46
0

Comparison of integrated development environments - C/C++ http://en.wikipedia.org/wiki/Comparison_of_integrated_development_environments#C.2FC.2B.2B

I use Code::Blocks with gcc and a GNU toolchain for embedded development on a Mac.

tyblu
  • 122
  • 1
  • 2
  • 10
0

If you are intended to build applications for MAC then best way is to learn "Objective C" and use Xcode editor on MAC. This will help you in long term as well. Xcode also allows you to build application using C/C++ and java, along with objective C.

A good way to start can be visiting this URL http://developer.apple.com/mac/, It has help also avail.

Unicorn
  • 2,382
  • 6
  • 29
  • 42
-2

C++ is not restricted to .exe files.... window PE files are one container format for machine code. A C++ binary can be encased in any low-level container format you can think of.

Objective-C on the mac can be a very pleasant language to learn, also Java. Do you really need to learn C++ at this junction ? C++ is suited to low-level programming problems -- i.e., video games, system software, and generally performance-critical software (photoshop and imovie).

Hassan Syed
  • 20,075
  • 11
  • 87
  • 171
  • 25
    Learning C++ before any other programming language can make it easier to learn new languages afterwards. C++ is a multi-paragdim language so it is possible to see multiple ways of programming inside one programming language. – Partial Mar 02 '10 at 21:45
  • 7
    @partial While that is a nice sentiment, it is counter-productive in practise -- people are mostly motivated to learn a language to gain the expertise to solve a problem, and they don't care about reaching enlightenment -- or perhaps to attain enlightenment through time and experience -- for example: Why sould someone wanting to drive to work know how to drive a rally car ? ? sure it might improve their situation when they try to drive on icy roads .... in practise they can just drive slowly 2 days a year. – Hassan Syed Mar 02 '10 at 22:27
  • 5
    ...icy roads, wet roads, bumpy roads, animal crossings, other drivers and so on. Yet if we had people with the experience, knowledge and reflexes of a rally driver on the road, there would be less accidents. The same can be said of programming. If you take the time to learn C++ you gain a certain mindset that will allow better programming in the end. Also, you will gain certain reflexes that you would not normally have with simpler programming language. This is not a sentiment, but a personal experience. – Partial Mar 03 '10 at 01:16
  • 9
    Are you really saying that C++ does not give people the expertise to solve problems? Why would "video games, system software, and generally performance-critical software (photoshop and imovie)" be made with C++? It is a complex language! So what? Get over it! When you learn how to program, you learn the basics of a programming language first. Not the other way around. C++ allows people to learn step by step from functional programming to meta-programming, from static memory allocation to dynamic memory allocation, from conditional statements to for_each loops with functors, etc. – Partial Mar 03 '10 at 01:35
  • 6
    I would agree with Partial. Even though the learning curve might be steeper for C/C++ but the experience definitely pays off. Another thing I observed is many people who start with 'easier to code' languages are later reluctant to learn C++ maybe because of they get comfortable coding without caring for memory management, pointers etc. – NSRover Jul 03 '12 at 12:16