ld: library not found for -lcrt0.o

ld: library not found for -lcrt0.o

背景:

Mac 系统编译的时候报错
语言:golang

原因:

代码使用了静态编译,-static。stack overflow 上说

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.


除非使用-static编译了所有的库(包括libgcc.a),否则此选项在Mac上不起作用。

解决方案:

  1. 删除 -static 进行编译。(亲测)
  2. 好像可以使用新版的 LLVM LLD linker。 详见 macOS - ld: library not found for -lcrt0.o on OSX 10.6 with gcc/clang -static flag - Stack Overflow

你可能感兴趣的:(golang踩坑,macos,golang,crt0.o,编译)