[LLVMdev] Problem linking class to a pass in a loadable module

Raphael Ernani Rodrigues raphael at dcc.ufmg.br
Thu Feb 28 12:59:38 PST 2013


Dear LLVMers,

I have a class X that represents a set of Value* in a specific way.
That class is stored in two files: X.cpp and X.h

The class X works perfectly in a pass that I already have.

However, I need to use that class in some other passes, but I don't
want to have a copy of X.cpp and X.h in every pass folder.

I've tried to do the following:

 - put X.h in the folder <llvm_root>/include/lllvm/Analysis
 - put X.cpp in the folder <llvm_root>/lib/Analysis

 - go to <llvm_root> and execute "make", to compile everything again,
with my new files

 - change the includes of my passes to replace #include "X.h"  by
#include "llvm/Analysis/X.h"

 - compile my pass again

Until this point everything works fine. Although everything compiles
without any warnings,
I can't run my pass after I change the location of the source code of
the class X.

When I use the command:
raphael at ubuntu:~/$ opt -f -load myPassModule.so -myPass test.bc

I get the following error message:
opt: symbol lookup error:
/host/Raphael/bin/llvm-3.2/Release+Asserts/bin/../lib/myPassModule.so:
undefined symbol: _ZN4llvm5GraphC1Ei


I know that this error message means that X.h was successfully linked
to myPass, but when I call opt, opt can't find the actual
implementation
of the class and the methods declared in the header file.


Does anybody know what I did wrong or what I should do to make this work?



More information about the llvm-dev mailing list