g++ can't locate file?

Discussion in 'Mac Programming' started by ChrisBrightwell, Jan 26, 2005.

  1. macrumors 68020

    ChrisBrightwell

    Joined:
    Apr 5, 2004
    Location:
    Huntsville, AL
    #1
    Hi everyone,

    I'm not a programming n00b by any means, but my ability to troubleshoot CLI dev tools is relatively nil.

    Here's my command and the subsequent error:

    mario:~/Desktop chris$ g++ HelloWorld.cpp
    ld: can't locate file for: -lcrt1.o

    Any ideas? If I try it with the -c flag, it compiles but I can't do anything with it:

    mario:~/Desktop chris$ gcc -c HelloWorld.cpp
    mario:~/Desktop chris$ chmod +x HelloWorld.o
    mario:~/Desktop chris$ ./HelloWorld.o
    -bash: ./HelloWorld.o: Bad executable (or shared library)

    I'm stumped.
     
  2. macrumors member

    Joined:
    Oct 7, 2004
    #2
    i dont know what that strange error is, but you can make an executable straight out of g++ using the "-o" (output) flag. like this:

    g++ HelloWorld.cpp -o HelloWorld

    that creates an executable called HelloWorld that when double-clicked, will open up and run in the terminal. or you can ./ it and it'll work. No chmodding neccessary! :)
     
  3. thread starter macrumors 68020

    ChrisBrightwell

    Joined:
    Apr 5, 2004
    Location:
    Huntsville, AL
    #3
    Same error. Thanks, though.

    I'm going to try to reinstall Xcode and the developer tools. Maybe that'll do it.
     
  4. thread starter macrumors 68020

    ChrisBrightwell

    Joined:
    Apr 5, 2004
    Location:
    Huntsville, AL
    #4
    Downloaded and installed Xcode 1.5 and it worked. The version on my CD (which came with Panther, obviously) was 1.0 and Software Update would only update it to 1.1.

    Weird, but whatever. It works now. :)
     
  5. macrumors regular

    Joined:
    Dec 24, 2002
    Location:
    Chicagoland
    #5
    Really? It went away?

    Thanks, that actually helps me. I had the same problem.

    Of course, when I try to download Xcode 1.5, it gives me a 404 error. Just my freakin' unbelievable luck.
     

Share This Page