I am just getting started with llvm. Here's code I am trying to compile: #include <stdio.h>#include "llvm/IR/LLVMContext.h"#include "llvm/IR/Module.h"#include "llvm/IR/IRBuilder.h" int main(){ llvm::LLVMContext& context = llvm::getGlobalContext(); llvm::Module* module = new llvm::Module("top", context); llvm::IRBuilder<> builder(context); module->dump( );} when i compile with : llvm-g++ try.cpp -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS `llvm-config --cxxflags --ldflags --libs` I get the a.out file. No worries. But, I am interested in getting the LLVM IR file.So, I compiled with llvm-g++ try.cpp -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -S -emit-llvm lli try.s I get an error saying LLVM ERROR: Program used external function '_ZN4llvm16getGlobalContextEv' which could not be resolved! The command : llvm-g++ try.cpp -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS `llvm-config --cxxflags --ldflags --libs` -S -emit-llvm leaves me with several warnings and when i execute the resultant .s file with lli , I get the same error as before. Thanks a lot for your help Thank you, Prakash Premkumar -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140801/bf434f6d/attachment.html>
For some reasons lli and other tools is not compiled with -fPIC -rdynamic flags,so you have to append -extra-object=/path/to/llvmlib to let lli resolve them. 2014-08-01 20:42 GMT+08:00 Prakash Premkumar <prakash.prax at gmail.com>:> I am just getting started with llvm. > > Here's code I am trying to compile: > > #include <stdio.h> > #include "llvm/IR/LLVMContext.h" > #include "llvm/IR/Module.h" > #include "llvm/IR/IRBuilder.h" > > > int main() > { > llvm::LLVMContext& context = llvm::getGlobalContext(); > llvm::Module* module = new llvm::Module("top", context); > llvm::IRBuilder<> builder(context); > > module->dump( ); > } > > when i compile with : > > llvm-g++ try.cpp -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS > `llvm-config --cxxflags --ldflags --libs` > > I get the a.out file. No worries. > > But, I am interested in getting the LLVM IR file.So, I compiled with > > llvm-g++ try.cpp -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -S > -emit-llvm > lli try.s > > I get an error saying > > LLVM ERROR: Program used external function '_ZN4llvm16getGlobalContextEv' > which could not be resolved! > > The command : > > llvm-g++ try.cpp -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS > `llvm-config --cxxflags --ldflags --libs` -S -emit-llvm > > leaves me with several warnings and when i execute the resultant .s file > with lli , I get the same error as before. > > Thanks a lot for your help > > > Thank you, > > Prakash Premkumar > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
Thanks a lot waxiadao . can you kindly tell me the exact commands that I will have to use? On 3 Aug 2014 15:49, "waxiadao at gmail.com" <waxiadao at gmail.com> wrote:> For some reasons lli and other tools is not compiled with -fPIC > -rdynamic flags,so you have to append -extra-object=/path/to/llvmlib > to let lli resolve them. > > 2014-08-01 20:42 GMT+08:00 Prakash Premkumar <prakash.prax at gmail.com>: > > I am just getting started with llvm. > > > > Here's code I am trying to compile: > > > > #include <stdio.h> > > #include "llvm/IR/LLVMContext.h" > > #include "llvm/IR/Module.h" > > #include "llvm/IR/IRBuilder.h" > > > > > > int main() > > { > > llvm::LLVMContext& context = llvm::getGlobalContext(); > > llvm::Module* module = new llvm::Module("top", context); > > llvm::IRBuilder<> builder(context); > > > > module->dump( ); > > } > > > > when i compile with : > > > > llvm-g++ try.cpp -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS > > `llvm-config --cxxflags --ldflags --libs` > > > > I get the a.out file. No worries. > > > > But, I am interested in getting the LLVM IR file.So, I compiled with > > > > llvm-g++ try.cpp -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -S > > -emit-llvm > > lli try.s > > > > I get an error saying > > > > LLVM ERROR: Program used external function '_ZN4llvm16getGlobalContextEv' > > which could not be resolved! > > > > The command : > > > > llvm-g++ try.cpp -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS > > `llvm-config --cxxflags --ldflags --libs` -S -emit-llvm > > > > leaves me with several warnings and when i execute the resultant .s file > > with lli , I get the same error as before. > > > > Thanks a lot for your help > > > > > > Thank you, > > > > Prakash Premkumar > > > > > > _______________________________________________ > > LLVM Developers mailing list > > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140803/4092c416/attachment.html>
Hi Waxiado, Chris and Tim, when i compiled with :> $ clang++ -g try.cpp `llvm-config --cppflags --ldflags --libs core jit > native`-o3 -S -emit-llvmI get the following warnings> clang: warning: -lz: 'linker' input unused > clang: warning: -lpthread: 'linker' input unused > clang: warning: -lcurses: 'linker' input unused > clang: warning: -lm: 'linker' input unused > clang: warning: -lLLVMX86Disassembler: 'linker' input unused > clang: warning: -lLLVMX86AsmParser: 'linker' input unused > clang: warning: -lLLVMX86CodeGen: 'linker' input unused > clang: warning: -lLLVMSelectionDAG: 'linker' input unused > clang: warning: -lLLVMAsmPrinter: 'linker' input unused > clang: warning: -lLLVMMCParser: 'linker' input unused > clang: warning: -lLLVMX86Desc: 'linker' input unused > clang: warning: -lLLVMX86Info: 'linker' input unused > clang: warning: -lLLVMX86AsmPrinter: 'linker' input unused > clang: warning: -lLLVMX86Utils: 'linker' input unused > clang: warning: -lLLVMJIT: 'linker' input unused > clang: warning: -lLLVMRuntimeDyld: 'linker' input unused > clang: warning: -lLLVMExecutionEngine: 'linker' input unused > clang: warning: -lLLVMCodeGen: 'linker' input unused > clang: warning: -lLLVMObjCARCOpts: 'linker' input unused > clang: warning: -lLLVMScalarOpts: 'linker' input unused > clang: warning: -lLLVMInstCombine: 'linker' input unused > clang: warning: -lLLVMTransformUtils: 'linker' input unused > clang: warning: -lLLVMipa: 'linker' input unused > clang: warning: -lLLVMAnalysis: 'linker' input unused > clang: warning: -lLLVMTarget: 'linker' input unused > clang: warning: -lLLVMMC: 'linker' input unused > clang: warning: -lLLVMObject: 'linker' input unused > clang: warning: -lLLVMCore: 'linker' input unused > clang: warning: -lLLVMSupport-o3: 'linker' input unused > clang: warning: argument unused during compilation: '-L/usr/local/lib'and when i compile the .s file with lli i get LLVM ERROR: Program used external function '_ZN4llvm16getGlobalContextEv'> which could not be resolved!Can you kindly help me resolve it? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140804/e6c4f962/attachment.html>