[LLVMdev] Error when Inserting Global variable

Blind Faith person.of.book at gmail.com
Fri Feb 8 06:25:46 PST 2013


I'm writing an LLVM pass which modifies the LLVM IR code. However, I am
having trouble inserting global variables. For example, when I try to
insert a global variable using the following code.

llvm::Value *val = new llvm::GlobalVariable(mod,
llvm::Type::getInt32Ty(mod.getContext()),
false, llvm::GlobalValue::ExternalLinkage, 0, "myvar");

I get the following error.

opt: symbol lookup error: /home/hmushtaq/llvm/Debug+Asserts/lib/Basic3.so:
undefined symbol:
_ZN4llvm14GlobalVariableC1ERNS_6ModuleEPNS_4TypeEbNS_11GlobalValue12LinkageTypesEPNS_8ConstantERKNS_5TwineEPS0_bj
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 0 has
invalid symbol index 11
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 1 has
invalid symbol index 12
........

What is going on here?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130208/2e2330ad/attachment.html>


More information about the llvm-dev mailing list