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

  • Context: C/C++ 
  • Thread starter Thread starter 00PS
  • Start date Start date
Click For Summary
SUMMARY

This discussion focuses on using Xcode 3.1 for compiling C++ programs on macOS. Users transitioning from Windows environments, specifically those familiar with devC++, can utilize Xcode's built-in GCC compiler for compiling C++ code. The command line instructions provided include using 'gcc filename.c -o programname' to compile and './programname' to execute the program. For more complex projects, users are advised to create new projects in Xcode specifically for C++ files and refer to the Xcode manual for guidance.

PREREQUISITES
  • Familiarity with C and C++ programming languages
  • Basic understanding of command line operations in macOS Terminal
  • Knowledge of project creation in Xcode
  • Access to the Xcode manual for reference
NEXT STEPS
  • Learn how to use GCC for compiling C++ programs in macOS Terminal
  • Explore project creation in Xcode for C++ applications
  • Read "Cocoa Programming for Mac OS X" by Aaron Hillegass for deeper insights into Xcode
  • Investigate advanced features of Xcode IDE for C++ development
USEFUL FOR

Mac users transitioning from Windows who want to compile C++ programs, students learning C++, and developers seeking to utilize Xcode for application development.

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

  • · Replies 1 ·
Replies
1
Views
4K
Replies
6
Views
3K
  • · Replies 29 ·
Replies
29
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 8 ·
Replies
8
Views
14K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 13 ·
Replies
13
Views
31K
Replies
4
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 15 ·
Replies
15
Views
5K