<div dir="ltr"><div><div>I have just solved the problem by myself. <br><br>For those who have the same problem as I did: just put your source file BEFORE those linraries.<br><br></div>g++ <source-file-of-the-user> `llvm-config ...`<br><br></div>Following instrucitons on 'ld':<br><br>If any library A depends on symbols defined in library B, then library A should appear first in the list supplied to the linker<br><div><br></div><div>Voila.<br> <br></div><div>Zhoulai<br></div><div> <br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Apr 20, 2015 at 7:03 PM, Zhoulai <span dir="ltr"><<a href="mailto:zell08v@gmail.com" target="_blank">zell08v@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>Hi, <br><br></div>Excuse me but I have struggled with a  link issue when compiling this one-line program,  "Hello.cpp":<br><br><br>#include "llvm/Support/TargetSelect.h"<br>using namespace llvm;<br>int main(int argc, char **argv) {<br>  InitializeNativeTarget();<br><br>}<br><br></div>I use this command line:<br><div><br> g++ -o Hello  `llvm-config --libs --cxxflags --ldflags` ../src/Hello.cpp<br><br></div><div>The error message:<br><br>Hello.cpp:(.text._ZN4llvm22InitializeNativeTargetEv[_ZN4llvm22InitializeNativeTargetEv]+0x5): undefined reference to `LLVMInitializeX86TargetInfo'<br>Hello.cpp:(.text._ZN4llvm22InitializeNativeTargetEv[_ZN4llvm22InitializeNativeTargetEv]+0xa): undefined reference to `LLVMInitializeX86Target'<br>Hello.cpp:(.text._ZN4llvm22InitializeNativeTargetEv[_ZN4llvm22InitializeNativeTargetEv]+0xf): undefined reference to `LLVMInitializeX86TargetMC'<br>collect2: error: ld returned 1 exit status<br><br clear="all"></div><div><div><div><div><div>Any hint for the problem source? I am using LLVM 3.7 on a ubuntu 14.04 (VM). Thanks. <br clear="all"></div><span class="HOEnZb"><font color="#888888"><div><div><div><br>Zhoulai</div></div>
</div>
</font></span></div></div></div></div></div>
</blockquote></div><br></div></div>