[LLVMdev] link issue with InitializeNativeTarget

Zhoulai zell08v at gmail.com
Mon Apr 20 19:03:43 PDT 2015


Hi,

Excuse me but I have struggled with a  link issue when compiling this
one-line program,  "Hello.cpp":


#include "llvm/Support/TargetSelect.h"
using namespace llvm;
int main(int argc, char **argv) {
  InitializeNativeTarget();

}

I use this command line:

 g++ -o Hello  `llvm-config --libs --cxxflags --ldflags` ../src/Hello.cpp

The error message:

Hello.cpp:(.text._ZN4llvm22InitializeNativeTargetEv[_ZN4llvm22InitializeNativeTargetEv]+0x5):
undefined reference to `LLVMInitializeX86TargetInfo'
Hello.cpp:(.text._ZN4llvm22InitializeNativeTargetEv[_ZN4llvm22InitializeNativeTargetEv]+0xa):
undefined reference to `LLVMInitializeX86Target'
Hello.cpp:(.text._ZN4llvm22InitializeNativeTargetEv[_ZN4llvm22InitializeNativeTargetEv]+0xf):
undefined reference to `LLVMInitializeX86TargetMC'
collect2: error: ld returned 1 exit status

Any hint for the problem source? I am using LLVM 3.7 on a ubuntu 14.04
(VM). Thanks.

Zhoulai
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150420/267c5965/attachment.html>


More information about the llvm-dev mailing list