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/ec92d076/attachment.html>
What version of LLVM are you using? llvm-gcc was deprecated a long time ago, and while it doesn’t directly address your question, I suggest trying with clang(++). - Chris On Aug 1, 2014, at 8:32 AM, Prakash Premkumar <prakash.prax at gmail.com<mailto:prakash.prax at gmail.com>> wrote: 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<mailto: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/20140801/ee35eb6c/attachment.html>
Thank you Chris. I am using llvm-3.4.2. I am facing the same issue when using clang++ as well. $ clang++ try.cpp -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS `llvm-config --cxxflags --ldflags --libs` -S -emit-llvm gives me errors $clang++ try.cpp -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -S -emit-llvm $ lli try.s gives me Program used external function '_ZN4llvm16getGlobalContextEv' which could not be resolved! Thank you On Fri, Aug 1, 2014 at 7:25 PM, Chris Cadwallader <ccadwallader at arxan.com> wrote:> What version of LLVM are you using? llvm-gcc was deprecated a long time > ago, and while it doesn’t directly address your question, I suggest trying > with clang(++). > > - Chris > > On Aug 1, 2014, at 8:32 AM, Prakash Premkumar <prakash.prax at gmail.com> > wrote: > > 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/20140802/49c1e874/attachment.html>