<div>HI Duncan,</div><div><br></div><div>Your understanding of the problem is correct. However, the XYZ class is not inside an anonymous name space. Also, all the XYZ methods are defined in the .cpp file. Looking at the error message:</div>
<div><br></div><div><div>opt: symbol lookup error: path/to/pass.so: undefined symbol: _ZN12DataTransferD1Ev</div></div><div><br></div><div>Where DataTransfer is the class name. Maybe I am missing certain type of constructors?</div>
<div><br></div><div>Thanks,</div><div>Welson</div><div><br></div><div><br></div><br><br><div class="gmail_quote">On Thu, Mar 1, 2012 at 10:00 AM, Duncan Sands <span dir="ltr"><<a href="mailto:baldrick@free.fr">baldrick@free.fr</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Welson, are you saying that the .o file containing the class is being linked<br>
into the .so file, but nonetheless you get "undefined symbol XYZ" errors where<br>
XYZ is that class?  Maybe you defined the class inside an anonymous name space?<br>
Alternatively, if XYZ refers to a method of the class, maybe you forgot to<br>
define that method.<br>
<br>
Ciao, Duncan.<br>
<div class="im"><br>
On 01/03/12 17:36, Welson Sun wrote:<br>
> Originally, the problem is the lack of .cpp file. Then I noticed the compilation<br>
> log is not showing the .o file being generated for the non-pass classes.<br>
><br>
> Then I added the .cpp files for each .h file, then the .o files are being<br>
> generated, shown in the Debug directory. Actually, if I add "VERBOSE = 1" in the<br>
> Makefile, it shows the linking command is actually linking all the .o files into<br>
> the pass.so file.<br>
><br>
> Any help will be appreciated.<br>
><br>
> Thanks!<br>
> Welson<br>
><br>
><br>
> On Thu, Mar 1, 2012 at 6:45 AM, John Criswell <<a href="mailto:criswell@illinois.edu">criswell@illinois.edu</a><br>
</div><div class="im">> <mailto:<a href="mailto:criswell@illinois.edu">criswell@illinois.edu</a>>> wrote:<br>
><br>
>     On 2/29/12 11:03 PM, Welson Sun wrote:<br>
>>     My pass uses another class which is defined in a separate .h file, which<br>
>>     sits in the same folder as the pass .cpp file. The pass compiles fine, but<br>
>>     when using the pass "opt -load ...", there is an error: opt symbol lookup<br>
>>     error  .... undefined symbol xxx,  where xxx is the class name. It looks<br>
>>     like that class file's object file is not linked into the pass.so file.<br>
>>     How should I change the Makefile to make the linking happen?<br>
><br>
>     If your .cpp file isn't including the .h file, then the class in the .h file<br>
>     isn't being compiled and, therefore, isn't being included in the final<br>
>     library file.<br>
><br>
>     Classes should be declared in header files and have their methods defined in<br>
>     .cpp files.  That's the easiest way to fix the problem.<br>
><br>
>     -- John T.<br>
><br>
><br>
>><br>
>>     Thanks,<br>
>>     Welson<br>
>><br>
>><br>
>>     _______________________________________________<br>
>>     LLVM Developers mailing list<br>
</div>>>     <a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>  <mailto:<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>>          <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>

<div class="im">>>     <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
><br>
><br>
>     _______________________________________________<br>
>     LLVM Developers mailing list<br>
</div>>     <a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <mailto:<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>

<div class="im">>     <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
><br>
><br>
><br>
><br>
> --<br>
> Welson<br>
><br>
> Phone: <a href="tel:%28408%29%20418-8385" value="+14084188385">(408) 418-8385</a><br>
</div>> Email: <a href="mailto:welson.sun@gmail.com">welson.sun@gmail.com</a> <mailto:<a href="mailto:welson.sun@gmail.com">welson.sun@gmail.com</a>><br>
<div class="HOEnZb"><div class="h5">><br>
><br>
><br>
><br>
> _______________________________________________<br>
> LLVM Developers mailing list<br>
> <a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Welson<div><br></div><div>Phone: (408) 418-8385</div><div>Email:  <a href="mailto:welson.sun@gmail.com" target="_blank">welson.sun@gmail.com</a></div>
<div><br></div><br>