Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ld: library not found for -lcrt0.o on OSX 10.6 with gcc/clang -static flag

Tags:

macos

gcc

ld

When I try to build the following program:

#include <stdio.h>  int main(void) {   printf("hello world\n");   return 0; } 

On OS X 10.6.4, with the following flags:

gcc -static -o blah blah.c 

It returns this:

ld: library not found for -lcrt0.o collect2: ld returned 1 exit status 

Has anyone else encountered this, or is it something that noone else has been affected with yet? Any fixes?

Thanks

like image 970
browneye Avatar asked Sep 27 '10 03:09

browneye


People also ask

Does Mac use Clang or gcc?

Clang is also provided in all major BSD or GNU/Linux distributions as part of their respective packaging systems. From Xcode 4.2, Clang is the default compiler for Mac OS X.

How do I find gcc on Mac?

You can run brew info gcc to get path where it is installed and get exact name of the binary by listing the directory. $ brew info gcc gcc: stable 11.2. 0 (bottled), HEAD GNU compiler collection https://gcc.gnu.org/ /usr/local/Cellar/gcc/11.2.

Is gcc preinstalled in Mac?

Often times, you need c or gcc compiler to compile open source projects in Mac OS X. The problem is Mac OS X doesn't install the gcc compiler by default. In terminal, type “ gcc “, you will get message “command not found”.


1 Answers

This won’t work. From the man page for gcc:

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.

like image 86
Nate Avatar answered Sep 19 '22 15:09

Nate