View Full Version : g++ can't locate file?

Jan 26, 2005, 11:58 PM
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.

Jan 27, 2005, 08:22 AM
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! :)

Jan 27, 2005, 09:34 AM
Same error. Thanks, though.

I'm going to try to reinstall Xcode and the developer tools. Maybe that'll do it.

Jan 27, 2005, 02:08 PM
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. :)

Zion Grail
Jan 28, 2005, 09:39 PM
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.