[LLVMdev] Linking problem in a pass

Duncan Sands baldrick at free.fr
Thu Mar 1 10:00:42 PST 2012


Hi Welson, are you saying that the .o file containing the class is being linked
into the .so file, but nonetheless you get "undefined symbol XYZ" errors where
XYZ is that class?  Maybe you defined the class inside an anonymous name space?
Alternatively, if XYZ refers to a method of the class, maybe you forgot to
define that method.

Ciao, Duncan.

On 01/03/12 17:36, Welson Sun wrote:
> Originally, the problem is the lack of .cpp file. Then I noticed the compilation
> log is not showing the .o file being generated for the non-pass classes.
>
> Then I added the .cpp files for each .h file, then the .o files are being
> generated, shown in the Debug directory. Actually, if I add "VERBOSE = 1" in the
> Makefile, it shows the linking command is actually linking all the .o files into
> the pass.so file.
>
> Any help will be appreciated.
>
> Thanks!
> Welson
>
>
> On Thu, Mar 1, 2012 at 6:45 AM, John Criswell <criswell at illinois.edu
> <mailto:criswell at illinois.edu>> wrote:
>
>     On 2/29/12 11:03 PM, Welson Sun wrote:
>>     My pass uses another class which is defined in a separate .h file, which
>>     sits in the same folder as the pass .cpp file. The pass compiles fine, but
>>     when using the pass "opt -load ...", there is an error: opt symbol lookup
>>     error  .... undefined symbol xxx,  where xxx is the class name. It looks
>>     like that class file's object file is not linked into the pass.so file.
>>     How should I change the Makefile to make the linking happen?
>
>     If your .cpp file isn't including the .h file, then the class in the .h file
>     isn't being compiled and, therefore, isn't being included in the final
>     library file.
>
>     Classes should be declared in header files and have their methods defined in
>     .cpp files.  That's the easiest way to fix the problem.
>
>     -- John T.
>
>
>>
>>     Thanks,
>>     Welson
>>
>>
>>     _______________________________________________
>>     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
>
>
>     _______________________________________________
>     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
>
>
>
>
> --
> Welson
>
> Phone: (408) 418-8385
> Email: welson.sun at gmail.com <mailto:welson.sun at gmail.com>
>
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list