Starting with C++, getting non-existant error message

Discussion in 'Mac Programming' started by Zion Grail, Jan 24, 2005.

  1. macrumors regular

    Dec 24, 2002
    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?
  2. macrumors 6502

    May 12, 2003
    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. :D
  3. macrumors newbie

    Aug 5, 2003
    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.
  4. thread starter macrumors regular

    Dec 24, 2002

    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
  5. thread starter macrumors regular

    Dec 24, 2002
    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.
  6. macrumors member


    Jan 8, 2005
    Aalborg, Denmark
    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. :)

Share This Page