We are taught C++ at our college. There, we just launch Turbo C++ and start typing. But how do I write C++ programs on a Mac? Is there something like Turbo C++ available? A search on MacUpdate did not reveal anything at all.
And it comes on your Mac's System Install and Restore Disks. Latest version, 2.4.1, is available online at http://developer.apple.com/. get a free account, log in and go to downloads. It weights about 750MB.
Funny.. I remembered that gcc comes in the base install but apparently only javac does, and gcc inside Dev Tools.
Anyway, for someone new to C++ and... other scary things... vi's a little harsh. And I say that as a regular vim user. I'd say an easy GUI editor (?) and g++ would be best.
Having learned that route, one can always jump into an IDE and knows what everything means. Starting from an IDE and growing a dependency makes people very uneasy to step outside it because the IDE does so much different stuff, it seems like magic. I'm sure Kickaha will disagree here
Feh. I cut my teeth on a Z19 terminal. I *still* do 90% of my programming outside of IDEs of any sort, and it wasn't until two years ago that I started using a GUI text editor (TextMate - utterly rocks) over vi. Most of the environments I work in these days don't have anything resembling a IDE anyways.
Make for the win.
I'm a firm believer in knowing what's going on under the covers of my tools. When I started learning Xcode, I was constantly checking tool chain arguments, XML files, etc, etc, just so I could step in and override when necessary.
IDEs are great for getting you going along an established workflow, but setting *up* that workflow can suck green goats.
Know your tools, from the bottom up, is my feeling.
OTOH, when you're in a class setting, getting the grade is the goal, not necessarily learning the tools (curse you educational system!). In that case, whatever makes your life easier so you can concentrate on whatever hoops the prof wants you to jump through is best.
I'm sorry for bumping an old thread but I still haven't gotten the reply I wanted to hear and I saw no point in starting a new thread.
Could someone just explain to me in layman's terms what exactly I need to do to compile my CPP files, i.e. those created on Windows using Turbo C++, on Mac OS X? If it can be done using the Terminal, how exactly do I go about doing it?
If your C++ projects are targeted for a POSIX platform (they reference the standard C/C++ libraries and that's about it), you can compile them in the terminal with gcc. If you don't know how to do that, ask for your money back on that class you took.
If your projects are targeted for windows or "Turbo C++," whatever that is, you may need to port them. Without knowing what you have done, it's hard to give you specific advice: other than reminding you that XCode is still the best solution here. It has many options, and last I checked it could be set up to compile to a POSIX shell, which I suspect is what you're trying to do.
Could someone just explain to me in layman's terms what exactly I need to do to compile my CPP files, i.e. those created on Windows using Turbo C++, on Mac OS X? If it can be done using the Terminal, how exactly do I go about doing it?
First, tell us what you are doing. Is this a "learning beginning C++" exercise and you are basically using cout/cin and the << and >> operators to output and input the program's data? Of are you trying to take advantage of Turbo C++ specific features? C++ is the ultimate in being able to use extensible libraries, but those libraries may have platform-specific underbellies that are hidden -- abstracted, actually -- away from you. (Step into cout sometime with your debugger, lotsa hairy C code in there...)
If you were creating a command-line program to get some data, put it into some basic C++ objects (maybe even manipulating an array of pointers to inherited instantiations of those objects for polymorphism), fold/spindle/mutilate and output the results to demonstrate features, your C++ needs could probably be met with g++, etc.
Instead, if you are developing a professional looking GUI application, well that would be a beast of a different color.
So tell us what you are trying to do and we'll tell you how low-end you can go.
Edit: IMO, an integrated interactive debugger is worth its weight in gold. Its one thing to be able to look at the addresses stored in a pointer, its another to be able to automatically de-reference the value or object in that address to something understandable. In my earlier ramblings, if you had an array/linked list/whatever of pointers to a group of objects, its really nice to be able to set a breakpoint, and not only evaluate whether that pointer is valid or if it points to garbage. But to be able to de-reference the pointer to an object that, say, has a name property or a getName() method to see if its the object you thought it was... You don't get that creating a make file and running some .cpp code into a compiler.
Edit: IMO, an integrated interactive debugger is worth its weight in gold. Its one thing to be able to look at the addresses stored in a pointer, its another to be able to automatically de-reference the value or object in that address to something understandable. In my earlier ramblings, if you had an array/linked list/whatever of pointers to a group of objects, its really nice to be able to set a breakpoint, and not only evaluate whether that pointer is valid or if it points to garbage. But to be able to de-reference the pointer to an object that, say, has a name property or a getName() method to see if its the object you thought it was... You don't get that creating a make file and running some .cpp code into a compiler.
Meh... just don't write so many bugs into the code.
But I have tried X Code, Code Blocks and eclipse on my mac but sadly none of them have compilers as they can't even run a simple display program. But I really like the ide of XCode. Only if there was a way to compile and run the programs.
But I have tried X Code, Code Blocks and eclipse on my mac but sadly none of them have compilers as they can't even run a simple display program. But I really like the ide of XCode. Only if there was a way to compile and run the programs.
You need to read the documentation a little before getting distraught. They ALL are include compilers, and all will compile files, build executables and launch them via their IDE GUIs.
Look up 'build' and 'compile', I'm sure you will find what you need there.
I appreciate the question because I had the same question! I know Stack Overflow hates these questions but I've never coded C++ on my Macbook.
You need to install the Mac Developer Tools either from your original Mac OS X disk or by downloading the latest version. This package includes the GCC compiler collection (supporting the C and C++ languages, amongst others).
Basically you should get a (free) developer account and then download Xcode.
Unfortunately, starting with Xcode 4, Apple is charging 5$ for the download. So you could either decide to pay this, or download the previous version (Xcode 3)The main page for Xcode is this. There you will find links to Xcode 4 and Xcode 3 (search within the page)
Follow the instructions carefully.
Download Xcode
Install Xcode
Starting a New Project
Coding Compiling and Running
This tutorial is to help out anyone that wants to create a terminal based c++ program using Xcode for Mac OS X. This is mainly for the people in CS 150 at ODU, but I think many can benefit from this as a getting started guide. If you know some basic C++ already this guide will be easier to you, but no prior knowledge is required for this how-to.
Comments
I found two applications - CPP Edit and TryC. Are they any good? Are there any other alternatives?
I mean, if you really want to go minimalist, you could just use vi and g++ in the Terminal.
Anyway, for someone new to C++ and... other scary things... vi's a little harsh. And I say that as a regular vim user. I'd say an easy GUI editor (?) and g++ would be best.
Having learned that route, one can always jump into an IDE and knows what everything means. Starting from an IDE and growing a dependency makes people very uneasy to step outside it because the IDE does so much different stuff, it seems like magic. I'm sure Kickaha will disagree here
Make for the win.
I'm a firm believer in knowing what's going on under the covers of my tools. When I started learning Xcode, I was constantly checking tool chain arguments, XML files, etc, etc, just so I could step in and override when necessary.
IDEs are great for getting you going along an established workflow, but setting *up* that workflow can suck green goats.
Know your tools, from the bottom up, is my feeling.
OTOH, when you're in a class setting, getting the grade is the goal, not necessarily learning the tools (curse you educational system!). In that case, whatever makes your life easier so you can concentrate on whatever hoops the prof wants you to jump through is best.
Could someone just explain to me in layman's terms what exactly I need to do to compile my CPP files, i.e. those created on Windows using Turbo C++, on Mac OS X? If it can be done using the Terminal, how exactly do I go about doing it?
Thanks in advance.
If your projects are targeted for windows or "Turbo C++," whatever that is, you may need to port them. Without knowing what you have done, it's hard to give you specific advice: other than reminding you that XCode is still the best solution here. It has many options, and last I checked it could be set up to compile to a POSIX shell, which I suspect is what you're trying to do.
Could someone just explain to me in layman's terms what exactly I need to do to compile my CPP files, i.e. those created on Windows using Turbo C++, on Mac OS X? If it can be done using the Terminal, how exactly do I go about doing it?
First, tell us what you are doing. Is this a "learning beginning C++" exercise and you are basically using cout/cin and the << and >> operators to output and input the program's data? Of are you trying to take advantage of Turbo C++ specific features? C++ is the ultimate in being able to use extensible libraries, but those libraries may have platform-specific underbellies that are hidden -- abstracted, actually -- away from you. (Step into cout sometime with your debugger, lotsa hairy C code in there...)
If you were creating a command-line program to get some data, put it into some basic C++ objects (maybe even manipulating an array of pointers to inherited instantiations of those objects for polymorphism), fold/spindle/mutilate and output the results to demonstrate features, your C++ needs could probably be met with g++, etc.
Instead, if you are developing a professional looking GUI application, well that would be a beast of a different color.
So tell us what you are trying to do and we'll tell you how low-end you can go.
Edit: IMO, an integrated interactive debugger is worth its weight in gold. Its one thing to be able to look at the addresses stored in a pointer, its another to be able to automatically de-reference the value or object in that address to something understandable. In my earlier ramblings, if you had an array/linked list/whatever of pointers to a group of objects, its really nice to be able to set a breakpoint, and not only evaluate whether that pointer is valid or if it points to garbage. But to be able to de-reference the pointer to an object that, say, has a name property or a getName() method to see if its the object you thought it was...
Edit: IMO, an integrated interactive debugger is worth its weight in gold. Its one thing to be able to look at the addresses stored in a pointer, its another to be able to automatically de-reference the value or object in that address to something understandable. In my earlier ramblings, if you had an array/linked list/whatever of pointers to a group of objects, its really nice to be able to set a breakpoint, and not only evaluate whether that pointer is valid or if it points to garbage. But to be able to de-reference the pointer to an object that, say, has a name property or a getName() method to see if its the object you thought it was...
Meh... just don't write so many bugs into the code.
Meh... just don't write so many bugs into the code.
From my experience, the guy who says his code is 100% bug free is either delusional, writing only toy programs, or both.
From my experience, the guy who says his code is 100% bug free is either delusional, writing only toy programs, or both.
I'm glad you found it funny. I wasn't sure if the sarcasm would work via the web.
But I have tried X Code, Code Blocks and eclipse on my mac but sadly none of them have compilers as they can't even run a simple display program. But I really like the ide of XCode. Only if there was a way to compile and run the programs.
You need to read the documentation a little before getting distraught. They ALL are include compilers, and all will compile files, build executables and launch them via their IDE GUIs.
Look up 'build' and 'compile', I'm sure you will find what you need there.
I appreciate the question because I had the same question! I know Stack Overflow hates these questions but I've never coded C++ on my Macbook.
You need to install the Mac Developer Tools either from your original Mac OS X disk or by downloading the latest version. This package includes the GCC compiler collection (supporting the C and C++ languages, amongst others).
Basically you should get a (free) developer account and then download Xcode.
Unfortunately, starting with Xcode 4, Apple is charging 5$ for the download. So you could either decide to pay this, or download the previous version (Xcode 3)The main page for Xcode is this. There you will find links to Xcode 4 and Xcode 3 (search within the page)
Follow the instructions carefully.
This tutorial is to help out anyone that wants to create a terminal based c++ program using Xcode for Mac OS X. This is mainly for the people in CS 150 at ODU, but I think many can benefit from this as a getting started guide. If you know some basic C++ already this guide will be easier to you, but no prior knowledge is required for this how-to.