View Full Version : C++ in terminal
Aragorn
Jun 10, 2004, 05:32 PM
Hey, I'm new to posting, but have been reading the forums for about a year now. I am taking a summer C++ programming class and I need a way to compile my program on a mac. The class tells me how to do it on a Windows machine, but I would like to have my program work on my Mac. In windows I need to type in a compile command like this:
bgi++ -Wall sample.c -o nameofprogram
Is there a way to do this in the terminal, and if so do I need any special programs. I dont really care if I can send in my program, I just email the code for my homework. I just need it to compile and run on my computer. Any help would be great. Thanks.
belf8st
Jun 10, 2004, 05:57 PM
Hey, I'm new to posting, but have been reading the forums for about a year now. I am taking a summer C++ programming class and I need a way to compile my program on a mac. The class tells me how to do it on a Windows machine, but I would like to have my program work on my Mac. In windows I need to type in a compile command like this:
bgi++ -Wall sample.c -o nameofprogram
Is there a way to do this in the terminal, and if so do I need any special programs. I dont really care if I can send in my program, I just email the code for my homework. I just need it to compile and run on my computer. Any help would be great. Thanks.
Here you go. xcode includes gcc 3.3
http://developer.apple.com/tools/xcode/
link to the gcc documentation - http://gcc.gnu.org/onlinedocs/
GeeYouEye
Jun 10, 2004, 06:02 PM
or just g++ main.cpp -o program
Mitthrawnuruodo
Jun 10, 2004, 06:56 PM
I agree with GeeYouEye, do the g++ (or gcc or c++) command from terminal...
What does the -Wall flag do, I've never seen it before...
ElCrazon
Jun 10, 2004, 09:54 PM
-Wall it to display all warnings
Aragorn
Jun 10, 2004, 11:21 PM
Well it looks like the g++ code is working, but do I need to save my file as a .cpp? If so how do I do that? Should I use textedit, word or some other text software to save my files?
NuPowerbook
Jun 10, 2004, 11:35 PM
Well it looks like the g++ code is working, but do I need to save my file as a .cpp? If so how do I do that? Should I use textedit, word or some other text software to save my files?
Well, since you are going to be using the command line instead of something like, say, Xcode, why not use a command line text editor? Mac OS X comes with vim, emacs, pico, and I'm sure some others I don't know about.
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.