Why Can't I Compile With Terminal?

Joined
Apr 27, 2011
Messages
19
Reaction score
0
Points
1
I've watched videos of people compiling C++ that they wrote in terminal with the command g++ Project.cpp -o main

Why won't this work for me?
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
You need to be more specific - what isn't working? Error messages? Are you familiar with the Terminal? Have you installed Xcode?
 

Raz0rEdge

Well-known member
Staff member
Moderator
Joined
Jul 17, 2009
Messages
15,764
Reaction score
2,103
Points
113
Location
MA
Your Mac's Specs
2022 Mac Studio M1 Max, 2023 M2 MBA
Being vague and mysterious does't help to get you meaningful answers here...as @vansmith said, be more specific about what problems you are seeing..

Where did you get the Project.cpp file from, did you create it yourself? What does it contain??
 
OP
L
Joined
Apr 27, 2011
Messages
19
Reaction score
0
Points
1
Being vague and mysterious does't help to get you meaningful answers here...as @vansmith said, be more specific about what problems you are seeing..

Where did you get the Project.cpp file from, did you create it yourself? What does it contain??

I'm sorry, Project.cpp is a textfile i wrote my C++ source code in. I just purchased this mac and no I don't have xcode installed. Do I need xcode to be able to compile things with g++?
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
Yep, you need Xcode installed. Once you have that installed, you should be good to go.
 
OP
L
Joined
Apr 27, 2011
Messages
19
Reaction score
0
Points
1
Yep, you need Xcode installed. Once you have that installed, you should be good to go.

The xcode in the app store requires lion which I have been holding off on upgrading to and the one for download on apples website says you have to be a developer to get it which costs 99$...is there any other way to get this? I just want to be able to compile c++ programs from my macbook pro instead of always having to go to the computer lab.
 
Joined
May 19, 2009
Messages
8,428
Reaction score
295
Points
83
Location
Waiting for a mate . . .
Your Mac's Specs
21" iMac 2.9Ghz 16GB RAM - 10.11.3, iPhone6s & iPad Air 2 - iOS 9.2.1, ATV 4Th Gen tvOS, ATV3
If you are running SnowLeopard if I'm correct it should be on the 'other" install DVD. . . .
 
OP
L
Joined
Apr 27, 2011
Messages
19
Reaction score
0
Points
1
I only have two dvds with it. I have one that is the operating system and the other one say applications. I put the applications one in and all it has on it is the basic software that already came on my macbook such as idvd, imovie, etc.
 
Joined
Mar 17, 2008
Messages
6,879
Reaction score
191
Points
63
Location
Tucson, AZ
Your Mac's Specs
Way... way too many specs to list.
xCode should be on the OS disk as well. At least as I recall
 

dtravis7


Retired Staff
Joined
Jan 4, 2005
Messages
30,133
Reaction score
703
Points
113
Location
Modesto, Ca.
Your Mac's Specs
MacMini M-1 MacOS Monterey, iMac 2010 27"Quad I7 , MBPLate2011, iPad Pro10.5", iPhoneSE
According this put in your Snow Leopard DVD while in Snow Leopard and open it. Look for Optional Installs. You should see an Xcode.mpkg. Read the url. Report back. I am going to check my SL DVD.

Mac OS X 10.6 Snow Leopard FAQ

Edit: Yes that URL is correct. It's there. Here are two screen shots.

Screen Shot 2011-09-28 at 9.50.42 PM.png

Screen Shot 2011-09-28 at 9.50.47 PM.png
 
Joined
May 19, 2009
Messages
8,428
Reaction score
295
Points
83
Location
Waiting for a mate . . .
Your Mac's Specs
21" iMac 2.9Ghz 16GB RAM - 10.11.3, iPhone6s & iPad Air 2 - iOS 9.2.1, ATV 4Th Gen tvOS, ATV3
Oops my mistake. Its not on the 'other' but did have a feeling it was somewhere !!!!
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top