Want to highlight a helpful answer? Upvote!

Did someone help you, or did an answer or User Tip resolve your issue? Upvote by selecting the upvote arrow. Your feedback helps others! Learn more about when to upvote >

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

ld: library not found for -lcrt0.o

Hi, I'm doing research at Memorial Sloan-Kettering Cancer Center, and I am trying to compile some c code with an intel compiler and a -static flag. I'm getting an error:
ld: library not found for -lcrt0.o
Does anyone know how to fix this?
Thanks, it's holding up my research!
Sean

iMac 24 inch, Mac OS X (10.5.5)

Posted on Mar 18, 2009 10:34 AM

Reply
23 replies

Mar 18, 2009 11:13 AM in response to orangekay

You are right, I don't understand how icc works completely in that it does seem to by calling a linker, ld, even though it's an icc command that starts the process.
You completely got the problem right though, there is no libcrt0.a file anywhere. The dynamic library that is used when I don't compile with -static is: -lcrt1.10.5.o, a different file altogether, and I can find it at:
/Developer/SDKs/MacOSX10.5.sdk/usr/lib/crt1.10.5.o for one location. I don't know for sure if that's the one it uses though. I got the "-lcrt1.10.5.o" info from putting a -v in the icc command line.

Mar 18, 2009 3:01 PM in response to Sean McGuffee

crt0.o looks like the startup module, which is system dependent. In other words you are trying to port your program from one system to another, and the target system probably uses a different startup module.

Your first try is to remove -lcrt0.o from the build command line and let the system link to its default startup code. However be aware that porting code is not usually a job for a beginner, and the absence of crt0.o may be only the start of the problems you'll need to solve.

Mar 18, 2009 4:52 PM in response to Sean McGuffee

Are you calling ld directly? If so, this is normal. Let the compiler call ld on it's own and it will bring in the startup code.

Under the hood when the compiler calls the linker for you it adds -lcrt1.10.5.o -lSystem

...

Oops, just read your post closer. I think you're screwed.

-static
On systems that support dynamic linking, this prevents linking with the shared libraries. On
other systems, this option has no effect.

This option will not work on Mac OS X unless all libraries (including libgcc.a) have also been
compiled with -static. Since neither a static version of libSystem.dylib nor crt0.o are
provided, this option is not useful to most people.



Eric

Message was edited by: ericmeyers

Mar 19, 2009 12:59 PM in response to RayNewbie

Well, my program takes 45 minutes to run on a small sample of data with gcc, but it only takes 15 minutes with icc. I can get it to work without -static. It seems completely irrational to me to do that, but I guess with the current state of a mac, that is what I'll have to do. I don't know why my program should have to go waste time reading directories of shared libraries, but I can't seem to do anything about it. Maybe in the end I'll have to install the gnu gcc myself with at -static option at that point, if I really want to waste time. For now, I'm just going to give up on mac supplying the static libraries for gcc. I guess it's far to much to ask for the most obviously important part of a computer to come automatically installed.

Mar 19, 2009 1:04 PM in response to RayNewbie

I guess I should also mention another reason this is frustrating. I want to be able to use one version of my code via CVS. However, I absolutely have to use -static in my makefile on the linux clusters I use. Thus, it's annoying to have to modify the makefile every time I update the program on the mac by taking the -static line out. Furthermore, it's annoying that my free copy of icc on linux is more capable than my expensive copy of icc on mac because of a silly preference someone at mac seems to have.

Mar 19, 2009 1:39 PM in response to Sean McGuffee

I'm not so sure you know what a shared library is or how one works, but I would suggest actually profiling your code before blaming all those tremendously expensive method resolutions that generally only happen once in the process' lifetime for your code's slowness. What's far too much is to ask for the most basic aspects of software development to come automatically installed in every end user's head.

Porting software from one operating system to another is generally not something a complete beginner should attempt unless they happen to enjoy the sort of frustration you're currently experiencing. If a tool you need to do your job only runs in Linux, then using Linux should be a no-brainer.

ld: library not found for -lcrt0.o

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.