C/C++ Learning Xcode for Mac Users Wanting to Compile C++ Programs

  • Thread starter Thread starter 00PS
  • Start date Start date
AI Thread Summary
To get started with C++ development on a Mac using Xcode, it's important to know that Xcode includes GCC, the Mac OS X compiler. Users can compile C programs directly in the Terminal by using the command "gcc filename.c -o programname" and run the output with "./programname". Unlike Windows, where executables are named with a .exe extension, Unix systems produce an output called a.out by default. For more complex projects with multiple files, specifying the output name with the "-o" option becomes essential. While Xcode may seem intimidating at first, it is a powerful IDE that becomes easier to navigate with use. For those looking to deepen their understanding of Xcode, resources like Aaron Hillegass's book "Cocoa Programming for Mac OS X" are recommended.
00PS
Messages
30
Reaction score
0
So I took C and C++ classes in high school, and can remember most of it, but all of that was under Windows (devC++ to be exact). After switching to a mac in college I recently download Xcode and was a little intimidated with all the "developer tools". I don't really plan to use that stuff any time soon, but wanted a C++ compiler that runs native on macs. Anyways can I get some help on getting started and just compiling written programs. Like I said no help needed with the C++ just the enviroment. Thanks!
 
Technology news on Phys.org
If you've installed XCode, then XCode has already covertly installed GCC, which is the Mac OS X compiler. If you want to use GCC without bothering with XCode, just open a new window in Terminal and say

gcc filename.c -o programname

to compile filename.c, then say

./programname

to run it.
 
what is the difference between filename.c and programname.c?
 
By default unix compilers generate an output executable called a.out (for historic reasons) rather than filename.exe on a dos machine.
You can tell gcc what to call the output executable with the "-o name" command.
When you get to more complicated programs you might have 100s of .c files so you have to tell the system what you want the output to be.
 
If you want to create a standard C++ class, create a new project that is a tool which is a C++ file. There's descriptions there. There's also the XCode manual that you can refer to which basically tells you which project to choose.

It's complex-looking at first, but XCode isn't that hard to use after awhile.

It's a great IDE, and this is coming from MinGW on the Windows platform.
 
BryanP said:
If you want to create a standard C++ class, create a new project that is a tool which is a C++ file. There's descriptions there. There's also the XCode manual that you can refer to which basically tells you which project to choose.

It's complex-looking at first, but XCode isn't that hard to use after awhile.

It's a great IDE, and this is coming from MinGW on the Windows platform.

I'm sorry, can you be more specific? I am using Xcode 3.1 if that is any consolation. :)
 
I highly recommend Aaron Hillegass's book Cocoa Programming for Mac OS X to learn how to use XCode and how to develop Mac applications.
 

Similar threads

Back
Top