【问题标题】:Linking with llvm clang llvm ld main not found找不到与 llvm clang llvm ld main 的链接
【发布时间】:2013-05-18 06:42:36
【问题描述】:
$ cat test.c
int printf(const char *, ...);
int main() { printf("ok\n");}

$ clang -c test.c
$ llvm-ld test.o -o test /usr/lib/crt1.o -lSystem
$ ./test
'main' function not found in module.
$ ld test.o -o test /usr/lib/crt1.o -lSystem
$ ./test
ok

我正在尝试用clang编译这个简单的程序,然后用llvm-ld链接它,我的目标是避免使用GNU ld。我一定是以错误的方式使用它?

【问题讨论】:

    标签: llvm


    【解决方案1】:

    llvm-ld 使用位码文件作为输入来获取可执行文件或将所有输入文件组合成一个新的位码文件。对于目标文件,您需要使用lld

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-01-13
      • 2020-05-10
      • 1970-01-01
      • 1970-01-01
      • 2022-01-22
      • 1970-01-01
      • 2021-06-07
      • 2012-01-26
      相关资源
      最近更新 更多