Hi,<br><br>I am trying to use some LLVM API in my C++ code, and I end up getting linker errors. I am working on Apple MacOSX Lion. Using g++ for the compile. It is the CreateGlobalStringPtr which is throwing the error. This is LLVM 3.0.<br>

<br>Here's the code<span style="background-color:rgb(255,255,255);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;font-size:14px;line-height:18px;text-align:left">I am trying to use some LLVM API in my C++ code, and I end up getting linker errors. I am working on Apple MacOSX Lion. Using g++ for the compile. It is the CreateGlobalStringPtr which is throwing the error. This is LLVM 3.0.</span><p style="margin-top:0px;margin-right:0px;margin-bottom:1em;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;border-style:initial;border-color:initial;font-size:14px;vertical-align:baseline;background-image:initial;background-color:rgb(255,255,255);clear:both;word-wrap:break-word;font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;line-height:18px;text-align:left">

Here's the code:</p><pre style="margin-top:0px;margin-bottom:10px;padding-top:5px;padding-right:5px;padding-bottom:5px;padding-left:5px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;border-style:initial;border-color:initial;font-size:14px;vertical-align:baseline;background-image:initial;background-color:rgb(255,255,255);font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;overflow-x:auto;overflow-y:auto;width:auto;max-height:600px;line-height:18px;text-align:left">

<code style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;border-style:initial;border-color:initial;vertical-align:baseline;background-image:initial;background-color:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif">#define __STDC_LIMIT_MACROS
#define __STDC_CONSTANT_MACROS

#include "llvm/Support/DataTypes.h"
#include "llvm/Support/IRBuilder.h"
#include "llvm/LLVMContext.h"
#include "llvm/Module.h"
#include "llvm/Constants.h"
#include "llvm/Function.h"
#include "llvm/BasicBlock.h"
int main()
{
  llvm::LLVMContext & context = llvm::getGlobalContext();
  llvm::Module *module = new llvm::Module("top", context);
  llvm::IRBuilder<> builder(context);
  llvm::Value *helloWorld = builder.CreateGlobalStringPtr("hello world!\n");
}</code></pre><pre style="margin-top:0px;margin-bottom:10px;padding-top:5px;padding-right:5px;padding-bottom:5px;padding-left:5px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;border-style:initial;border-color:initial;font-size:14px;vertical-align:baseline;background-image:initial;background-color:rgb(255,255,255);font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;overflow-x:auto;overflow-y:auto;width:auto;max-height:600px;line-height:18px;text-align:left">

And here's the error: </pre><pre style="margin-top:0px;margin-bottom:10px;padding-top:5px;padding-right:5px;padding-bottom:5px;padding-left:5px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;border-style:initial;border-color:initial;vertical-align:baseline;background-image:initial;background-color:rgb(255,255,255);overflow-x:auto;overflow-y:auto;width:auto;max-height:600px;text-align:left">

<font face="Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif"><span style="font-size:14px;line-height:18px">g++ e.cpp /Developer/Platforms/iPhoneOS.platform/Developer/usr/llvm-gcc-4.2/libexec/gcc/i686-apple-darwin10/4.2.1/libllvmgcc.dylib 
Undefined symbols for architecture x86_64:
  "llvm::ConstantExpr::getGetElementPtr(llvm::Constant*, llvm::ArrayRef<llvm::Value*>, bool)", referenced from:
      llvm::ConstantExpr::getInBoundsGetElementPtr(llvm::Constant*, llvm::ArrayRef<llvm::Value*>)in ccFB7xjg.o
  "llvm::GetElementPtrInst::getIndexedType(llvm::Type*, llvm::ArrayRef<llvm::Value*>)", referenced from:
      llvm::GetElementPtrInst::GetElementPtrInst(llvm::Value*, llvm::ArrayRef<llvm::Value*>, unsigned int, llvm::Twine const&, llvm::Instruction*)in ccFB7xjg.o
  "llvm::PointerType::get(llvm::Type*, unsigned int)", referenced from:
      llvm::GetElementPtrInst::GetElementPtrInst(llvm::Value*, llvm::ArrayRef<llvm::Value*>, unsigned int, llvm::Twine const&, llvm::Instruction*)in ccFB7xjg.o
  "llvm::Instruction::Instruction(llvm::Type*, unsigned int, llvm::Use*, unsigned int, llvm::Instruction*)", referenced from:
      llvm::GetElementPtrInst::GetElementPtrInst(llvm::Value*, llvm::ArrayRef<llvm::Value*>, unsigned int, llvm::Twine const&, llvm::Instruction*)in ccFB7xjg.o
  "llvm::GetElementPtrInst::init(llvm::Value*, llvm::ArrayRef<llvm::Value*>, llvm::Twine const&)", referenced from:
      llvm::GetElementPtrInst::GetElementPtrInst(llvm::Value*, llvm::ArrayRef<llvm::Value*>, unsigned int, llvm::Twine const&, llvm::Instruction*)in ccFB7xjg.o
  "llvm::IRBuilderBase::CreateGlobalString(llvm::StringRef, llvm::Twine const&)", referenced from:
      llvm::IRBuilder<true, llvm::ConstantFolder, llvm::IRBuilderDefaultInserter<true> >::CreateGlobalStringPtr(llvm::StringRef, llvm::Twine const&)in ccFB7xjg.o
  "llvm::ConstantInt::get(llvm::IntegerType*, unsigned long long, bool)", referenced from:
      llvm::IRBuilder<true, llvm::ConstantFolder, llvm::IRBuilderDefaultInserter<true> >::CreateGlobalStringPtr(llvm::StringRef, llvm::Twine const&)in ccFB7xjg.o
ld: symbol(s) not found for architecture x86_64</span></font></pre>