[LLVMdev] Errors linking against libLLVMCore

Rick Mann rmann at latencyzero.com
Tue Dec 25 22:32:14 PST 2012


I'm trying to make a library in Xcode that links against LLVM. I used the STL C++ template in Xcode 4.5.2, added libLLVMCore.a and libLLVMSupport.a to the link binaries phase, and made this call in my code:

	llvm::LLVMContext& llvmCTX = llvm::getGlobalContext();

I get link errors against std::string and other STL classes:

Undefined symbols for architecture x86_64:
  "std::string::copy(char*, unsigned long, unsigned long) const", referenced from:
      llvm::sys::Path::makeUnique(bool, std::string*) in libLLVMSupport.a(Path.o)
  "std::string::find(char const*, unsigned long, unsigned long) const", referenced from:
      llvm::sys::getDefaultTargetTriple() in libLLVMSupport.a(Host.o)
      .
      .
      .

Builds fine if I take out that line (the only line, so far) of LLVM code.

But code like this compiles fine:

	std::string s = "Hello world";
	std::printf("%s", s.c_str());

I figure I'm missing a lib, but I have no idea which.

TIA,

-- 
Rick







More information about the llvm-dev mailing list