[cfe-dev] Linking options

Chris Lattner clattner at apple.com
Wed May 28 10:00:24 PDT 2008


On May 28, 2008, at 5:09 AM, Eli Friedman wrote:

> On Wed, May 28, 2008 at 4:52 AM, Paolo Bolzoni <bolzoni at cs.unipr.it>  
> wrote:
>> Here a very simple program, t.cc:
>> Compiling command (taken almost one-to-one from clang executable  
>> linking):
>> g++ -o /dev/null \
>> t.cc \
>>
> Try putting your libraries in the following order: -lclangCodeGen
> -lclangAnalysis -lclangRewrite -lclangSEMA -lclangAST -lclangParse
> -lclangLex -lclangBasic -lLLVMBitWriter -lLLVMBitReader -lLLVMCodeGen
> -lLLVMTarget -lLLVMSupport -lLLVMCore -lLLVMSystem -lpthread -ldl -lm
>
> I'm not entirely sure how clang avoids running into this; I don't know
> very much about linker magic.

In the llvm side of things, we use llvm-config to wrangle the library  
dependencies and figure out what order to link things it.  llvm-config  
works by nm'ing the libraries and building a dependence graph.  It  
should work with clang, but I don't think anyone has tried making it  
work.  It would require rebuilding the llvm-config database after the  
clang libs are built.

-Chris



More information about the cfe-dev mailing list