[LLVMdev] Symbol not found in opt when using own pass

James Stanier j.stanier at sussex.ac.uk
Wed Apr 8 09:04:21 PDT 2009


Hi,

I fixed my problem and thought I'd follow up as I've seen it pop up a few
times before on the mailing list, and maybe it will be of some use to
somebody else in the future. The problem is a completely silly one.

When writing your own header files for inclusion in a pass, always make sure
that an implementing .cpp file is written. Don't try and be lazy by just
writing all of the functions in the header; the linker won't be able to find
them without .cpp file.

This (stupid) solution was tested on Mac and also Linux.

Best,

James


James Stanier wrote:
> 
> Hi everyone,
> 
> I have a terrible feeling I'm doing something really silly here, but I
> can't seem to solve the problem after a day of trying now. I'm currently
> writing my own pass which I am running by loading it into the opt tool.
> Everything I had written in the pass so far had worked, until I started
> declaring an #include of some extra header files which I had written
> myself (they are objects for modeling a graph I am constructing):
> 
> #include "VSDGNode.h"
> #include "VSDGPlace.h"
> #include "VSDGTransition.h"
> using namespace vsdg;
> 
> In my function for constructing my graph, I declare an object:
> 
>    VSDGTransition t;
> 
> however, at run-time, the pass fails with the following error:
> 
> dyld: lazy symbol binding failed: Symbol not found:
> __ZN4vsdg14VSDGTransitionC1Ev
>   Referenced from:
> /Users/js231/svn-check/js231/code/llvm-2.5/Release/lib/VSDGConstruct.0.0.0.dylib
>   Expected in: flat namespace
> 
> dyld: Symbol not found: __ZN4vsdg14VSDGTransitionC1Ev
>   Referenced from:
> /Users/js231/svn-check/js231/code/llvm-2.5/Release/lib/VSDGConstruct.0.0.0.dylib
>   Expected in: flat namespace
> 
> // Memory dump omitted...
> 
> Segmentation fault
> 
> Which seems to suggest that in the .dylib file the symbol cannot be found.
> However, actually looking at the .dylib file it appears to be in there. Is
> there some kind of linking problem with my pass, or is there something
> very stupid that I am or am not doing? I can provide any more information
> if needed, I just didn't want to make the post unreadable if it was an
> obvious answer.
> 
> Thanks very much, as ever.
> 
> James
> 

-- 
View this message in context: http://www.nabble.com/Symbol-not-found-in-opt-when-using-own-pass-tp22929616p22953901.html
Sent from the LLVM - Dev mailing list archive at Nabble.com.




More information about the llvm-dev mailing list