[LLVMdev] Static variable symbol not found error

John Criswell criswell at illinois.edu
Mon Jun 16 07:57:05 PDT 2014


On 6/16/14, 6:34 AM, Umer wrote:
>
> Hello,
>
> Here is the error:
>
> Error opening '../lib/LLVMENTRA.dylib': dlopen(../lib/LLVMENTRA.dylib, 
> 9): Symbol not found: __ZN8CiaoType14typeInstances1E
>
> typeInstances1 is a static variable defined in a class, whenever it is 
> used during a function pass I get this error see below a minimal class 
> definition.
>
>
> class A{
>  static MapVector<Type*, A *> typeInstances1;
>  public:
>  static CiaoType * create(Type* T)
>  {
>     if(CiaoType * CT= typeInstances1.lookup(T))
>         return CT;
>     else
>      //create new instance and return
>  }
> };
>
> As long as I don't call the create method, everything works fine. Any 
> idea why the static variable symbol is not found in the dynamic library?

I believe the problem is caused by the fact that a static class member 
variable has to be declared in a .cpp file somewhere.  I think the 
static variable in the class definition above is just a declaration 
(it's kind of like the difference between a function prototype and 
function declaration in C).

That said, I think you're better off not declaring typeInstances1 as 
static.  I think multiple instances of an LLVM pass are supposed to be 
able to run concurrently (e.g., two modules being analyzed by two 
threads of the same process), and so a FunctionPass and ModulePass 
instantiations should not share information with each other.

Regards,

John Criswell

>
>
> PS:
> here is how I load and run my pass using opt
>
> ./opt -analyze -load ../lib/LLVMENTRA.dylib -instnamer -mypass foo.ll
>
> Regards
> Umer
>
>
>
>
> _______________________________________________
> 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/20140616/552081c7/attachment.html>


More information about the llvm-dev mailing list