如何将库铛和LLVM链接链接 [英] How to link a library with clang and llvm-link

查看:420
本文介绍了如何将库铛和LLVM链接链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编译我的程序是这样,

I am compiling my program like this,

clang++ -O4 -emit-llvm file1.cpp -c -o file1.bc -pthread 
clang++ -O4 -emit-llvm file2.cpp -c -o file2.bc -pthread

llvm-link file1.bc file2.bc -o main.ll -S 

我如何指定带有链接的 -ldl

推荐答案

LLVM链接是一个程序,链接在一起LLVM IR文件合并为一个红外文件;你可以阅读更多关于它这里。它没有任何关系 LD 或链接目标文件链接在一起。

llvm-link is a program which "links" together LLVM IR files into a single IR file; you can read more about it here. It does not have any relation to ld or to linking object files together.

如果你想生成目标code和/或可执行文件,看到这些相关的问题:

If you do want to generate object code and/or executables, see these related questions:

  • How to generate machine code with llvm
  • llvm-link with external libraries

总之,你应该使用本地工具组装和连接( LD ,例如)虽然目前还生成目标文件,并在LLVM链接一些实验的支持。

In short, you should be using native tools for assembling and linking (as and ld, for instance), though there is currently some experimental support for generating object files and for linking in LLVM.

在任何情况下,锵本身可以调用平台连接器 - 实际上是默认的,当然你通过提供覆盖 -c

In any case, Clang itself can invoke a platform linker - that is actually the default, but of course you have overridden by providing -c.

这篇关于如何将库铛和LLVM链接链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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