Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Zion Grail

macrumors regular
Original poster
OK, I've gotten through one semester of Computer Science here at my new universiy. The first semester, we worked with Java. I did pretty good with it, but now we've moving on to C++.

I'm putting in the sample program, and I hit "Build" in Xcode and... it fails. It compiles, but doesn't build. I get one error message.

Unfortunately, it doesn't tell me what the message is. Seriously. It says the build failed with one error, I double-click on the error symbol, and it opens the error message window and it has nothing in it.

This is getting frustrating. Anyone have any thoughts?
 
Have you tried opening a Terminal window and using gcc? Type:

g++ <yourfile>

If you get no errors, your program is created and called "a.out". If you still get an error, maybe it will be more helpful. I don't know how to compile in Xcode... I'm all about the command line. 😀
 
When you make your project in Xcode select "C++ Tool" under "Command Line Utility" in the assistant. Then when the project is created it'll start you off with a file that already has the required linked libstdc++ and a main.cpp file with your int main(). When you run the program it'll put up a window with the cout, clog, cerr, etc text.
 
Actually...

That's exactly what I did, and I'm getting that strange "error but no error" result. (Note: Until Apple fixes the download link on their website, I'm stuck with Xcode 1.1.)

Using g++ gives me this error:

ld: can't locate file for: -lcrt1.o
 
The Solution!

For all those who are having trouble with this same thing, do this.

Go to /Applications/Installers/Xcode Tools/Packages/

Run "DevSDK.pkg"

The problem goes away.

If DevSDK.pkg isn't there, re-install the Xcode Tools from the Xcode Tools CD.
 
C++ can be pretty problematic at times (the support is very poor compared to that of C and Obj-C). Try getting the G++ compiler patch from ADC, and if you fail, try reinstalling the XCode utilities. 🙂
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.