How to link a library with clang and llvm-link

心已入冬 提交于 2019-12-23 06:21:04

问题


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 

How do I specify linking with -ldl


回答1:


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.

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

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.

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



来源:https://stackoverflow.com/questions/13802383/how-to-link-a-library-with-clang-and-llvm-link

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!