ld:在带有 gcc/clang -static 标志的 OSX 10.6 上找不到 -lcrt0.o 的库 [英] ld: library not found for -lcrt0.o on OSX 10.6 with gcc/clang -static flag

查看:62
本文介绍了ld:在带有 gcc/clang -static 标志的 OSX 10.6 上找不到 -lcrt0.o 的库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试构建以下程序时:

When I try to build the following program:

#include <stdio.h>

int main(void)
{
  printf("hello world
");
  return 0;
}

在 OS X 10.6.4 上,具有以下标志:

On OS X 10.6.4, with the following flags:

gcc -static -o blah blah.c

它返回这个:

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?

谢谢

推荐答案

这行不通.从 gccman 页面:

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:在带有 gcc/clang -static 标志的 OSX 10.6 上找不到 -lcrt0.o 的库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆