Hi All,<div><br></div><div>I was able to resolve the compile errors using llvm-config --cxxflags --ldflags --libs and then applying the same to g++ command line. </div><div><br></div><div>Arpan<br><br><div class="gmail_quote">

On Sun, Jan 22, 2012 at 11:26 PM, Dmitry N. Mikushin <span dir="ltr"><<a href="mailto:maemarcus@gmail.com">maemarcus@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Probably your g++ compiles x86_64 binary by default, but i686 dylib is supplied?<br>
<br>
Try:<br>
<br>
g++ -m32 e.cpp /Developer/Platforms/iPhoneOS.platform/Developer/usr/llvm-gcc-4.2/libexec/gcc/i686-apple-darwin10/4.2.1/libllvmgcc.dylib<br>
<br>
- D.<br>
<br>
2012/1/22 Arpan Sen <<a href="mailto:arpansen@gmail.com">arpansen@gmail.com</a>>:<br>
<div><div></div><div class="h5">> Hi,<br>
><br>
> I am trying to use some LLVM API in my C++ code, and I end up getting linker<br>
> errors. I am working on Apple MacOSX Lion. Using g++ for the compile. It is<br>
> the CreateGlobalStringPtr which is throwing the error. This is LLVM 3.0.<br>
><br>
> Here's the codeI am trying to use some LLVM API in my C++ code, and I end up<br>
> getting linker errors. I am working on Apple MacOSX Lion. Using g++ for the<br>
> compile. It is the CreateGlobalStringPtr which is throwing the error. This<br>
> is LLVM 3.0.<br>
><br>
> Here's the code:<br>
><br>
> #define __STDC_LIMIT_MACROS<br>
> #define __STDC_CONSTANT_MACROS<br>
><br>
> #include "llvm/Support/DataTypes.h"<br>
> #include "llvm/Support/IRBuilder.h"<br>
> #include "llvm/LLVMContext.h"<br>
> #include "llvm/Module.h"<br>
> #include "llvm/Constants.h"<br>
> #include "llvm/Function.h"<br>
> #include "llvm/BasicBlock.h"<br>
> int main()<br>
> {<br>
>   llvm::LLVMContext & context = llvm::getGlobalContext();<br>
>   llvm::Module *module = new llvm::Module("top", context);<br>
>   llvm::IRBuilder<> builder(context);<br>
>   llvm::Value *helloWorld = builder.CreateGlobalStringPtr("hello world!\n");<br>
> }<br>
><br>
> And here's the error:<br>
><br>
> g++ e.cpp<br>
> /Developer/Platforms/iPhoneOS.platform/Developer/usr/llvm-gcc-4.2/libexec/gcc/i686-apple-darwin10/4.2.1/libllvmgcc.dylib<br>
> Undefined symbols for architecture x86_64:<br>
>   "llvm::ConstantExpr::getGetElementPtr(llvm::Constant*,<br>
> llvm::ArrayRef<llvm::Value*>, bool)", referenced from:<br>
>       llvm::ConstantExpr::getInBoundsGetElementPtr(llvm::Constant*,<br>
> llvm::ArrayRef<llvm::Value*>)in ccFB7xjg.o<br>
>   "llvm::GetElementPtrInst::getIndexedType(llvm::Type*,<br>
> llvm::ArrayRef<llvm::Value*>)", referenced from:<br>
>       llvm::GetElementPtrInst::GetElementPtrInst(llvm::Value*,<br>
> llvm::ArrayRef<llvm::Value*>, unsigned int, llvm::Twine const&,<br>
> llvm::Instruction*)in ccFB7xjg.o<br>
>   "llvm::PointerType::get(llvm::Type*, unsigned int)", referenced from:<br>
>       llvm::GetElementPtrInst::GetElementPtrInst(llvm::Value*,<br>
> llvm::ArrayRef<llvm::Value*>, unsigned int, llvm::Twine const&,<br>
> llvm::Instruction*)in ccFB7xjg.o<br>
>   "llvm::Instruction::Instruction(llvm::Type*, unsigned int, llvm::Use*,<br>
> unsigned int, llvm::Instruction*)", referenced from:<br>
>       llvm::GetElementPtrInst::GetElementPtrInst(llvm::Value*,<br>
> llvm::ArrayRef<llvm::Value*>, unsigned int, llvm::Twine const&,<br>
> llvm::Instruction*)in ccFB7xjg.o<br>
>   "llvm::GetElementPtrInst::init(llvm::Value*, llvm::ArrayRef<llvm::Value*>,<br>
> llvm::Twine const&)", referenced from:<br>
>       llvm::GetElementPtrInst::GetElementPtrInst(llvm::Value*,<br>
> llvm::ArrayRef<llvm::Value*>, unsigned int, llvm::Twine const&,<br>
> llvm::Instruction*)in ccFB7xjg.o<br>
>   "llvm::IRBuilderBase::CreateGlobalString(llvm::StringRef, llvm::Twine<br>
> const&)", referenced from:<br>
>       llvm::IRBuilder<true, llvm::ConstantFolder,<br>
> llvm::IRBuilderDefaultInserter<true><br>
>>::CreateGlobalStringPtr(llvm::StringRef, llvm::Twine const&)in ccFB7xjg.o<br>
>   "llvm::ConstantInt::get(llvm::IntegerType*, unsigned long long, bool)",<br>
> referenced from:<br>
>       llvm::IRBuilder<true, llvm::ConstantFolder,<br>
> llvm::IRBuilderDefaultInserter<true><br>
>>::CreateGlobalStringPtr(llvm::StringRef, llvm::Twine const&)in ccFB7xjg.o<br>
> ld: symbol(s) not found for architecture x86_64<br>
><br>
><br>
</div></div>> _______________________________________________<br>
> LLVM Developers mailing list<br>
> <a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Regards, <br>   Arpan<br>-----------------------------------------------------------------------------------------------------------------<br>Reality is merely an illusion, albeit a very persistent one.<br>


</div>