ld:在OSX 10.6上使用gcc / clang -static标志找不到-lcrt0.o的库 [英] ld: library not found for -lcrt0.o on OSX 10.6 with gcc/clang -static flag
问题描述
当我尝试构建下列程序时:
When I try to build the following program:
#include <stdio.h>
int main(void)
{
printf("hello world\n");
return 0;
}
在OS X 10.6.4上,使用以下标记:
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
推荐答案
这是行不通的。从 man
页面 gcc
:
This won’t work. From the man
page for gcc
:
除非所有库(包括libgcc.a)都已使用-static编译,否则此选项在Mac OS X上将不起作用。由于既没有提供libSystem.dylib的静态版本也没有提供crt0.o,所以这个选项对大多数人没有用。
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.
这篇关于ld:在OSX 10.6上使用gcc / clang -static标志找不到-lcrt0.o的库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!