link problem with llvm-pass

Hi,

I tried to implement an 'llc'-like tool in my project to manage different passes and a target machine.

I use given llvm project structure to avoid problems but I have a link problem and don't know how to solve it:
The target machine uses 'FindUsedTypes' pass and when I try to use my target machine in the tool I got "Undefined symbols: "llvm::FindUsedTypes ... ld: symbol(s) not found"

I tried following link options:
LLVMLIBS = LLVMAnalysis.a
LINK_COMPONENTS = analysis
LINK_COMPONENTS = all
But nothing solved my problem (in fact the last made some other problems with code I never touched).

I would be very appreciated for any idea.

Thanks a lot
Nico

PS: output from "make VERBOSE=1"

llvm[2]: Linking Release executable llx (without symbols)
/Users/me/Work/code/llvm-2.4/mklib --tag=CXX --tag=disable-shared --mode=link g++ -I/Users/me/Work/code/llvm-2.4/include -I/Users/me/Work/code/synphony/llvmllila/build/include -I/Users/me/Work/code/synphony/llvmllila/build/tools/llx -I/Users/me/Work/code/synphony/llvmllila/include -I/Users/me/Work/code/synphony/llvmllila/tools/llx -D_DEBUG -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -O3 -fno-exceptions -Woverloaded-virtual -pedantic -Wall -W -Wwrite-strings -Wno-long-long -Wunused -Wno-unused-parameter -fstrict-aliasing -Wstrict-aliasing -O3 -rpath /Users/me/Work/code/synphony/llvmllila/build/Release//bin -export-dynamic -L/Users/me/Work/code/synphony/llvmllila/build/Release//lib -L/Users/me/Work/code/llvm-2.4/Release//lib -o /Users/me/Work/code/synphony/llvmllila/build/Release//bin/llx /Users/me/Work/code/synphony/llvmllila/build/tools/llx/Release/main.o -lLMABE -lPartition -lLLVMBitReader -lLLVMAnalysis -lLLVMTarget -lLLVMCore -lLLVMSupport -lLLVMSystem \
     -lpthread -lm
g++ -I/Users/me/Work/code/llvm-2.4/include -I/Users/me/Work/code/synphony/llvmllila/build/include -I/Users/me/Work/code/synphony/llvmllila/build/tools/llx -I/Users/me/Work/code/synphony/llvmllila/include -I/Users/me/Work/code/synphony/llvmllila/tools/llx -D_DEBUG -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -O3 -fno-exceptions -Woverloaded-virtual -pedantic -Wall -W -Wwrite-strings -Wno-long-long -Wunused -Wno-unused-parameter -fstrict-aliasing -Wstrict-aliasing -O3 -o /Users/me/Work/code/synphony/llvmllila/build/Release//bin/llx /Users/me/Work/code/synphony/llvmllila/build/tools/llx/Release/main.o -L/Users/me/Work/code/synphony/llvmllila/build/Release//lib -L/Users/me/Work/code/llvm-2.4/Release//lib -lLMABE -lPartition -lLLVMBitReader -lLLVMAnalysis -lLLVMTarget -lLLVMCore -lLLVMSupport -lLLVMSystem -lpthread -lm
Undefined symbols:
   "llvm::FindUsedTypes::ID", referenced from:
       __ZN4llvm13FindUsedTypes2IDE$non_lazy_ptr in libLMABE.a(LMAWriter.o)
   "typeinfo for llvm::FindUsedTypes", referenced from:
       __ZTIN4llvm13FindUsedTypesE$non_lazy_ptr in libLMABE.a(LMAWriter.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status
make[2]: *** [/Users/me/Work/code/synphony/llvmllila/build/Release//bin/llx] Error 1
make[1]: *** [all] Error 1
make: *** [all] Error 1

Dear Nico,

I believe you need to add LLVMipa to the list of libraries to link into your tool. FindUsedTypes::ID is defined in lib/Analysis/IPA.

I think it would be LLVMipa.a if you added it to LLVMLIBS and ipa if you added it to LINK_COMPONENTS.

-- John T.

Nico wrote:

Dear John,

thanks! I was irritated by the path of the header file/declaration.
It is not like the definition in a subdirectory. Sorry my fault.

Is there an overview where classes and link options are mapped to each other?

Kind regards,
Nico

Nico wrote:

Dear John,

thanks! I was irritated by the path of the header file/declaration.
It is not like the definition in a subdirectory. Sorry my fault.

Is there an overview where classes and link options are mapped to each other?
  

If there is one, I do not know of it.

My method for determining which library to link is twofold:

1) Since I have a general understanding of LLVM's libraries, I can make educated guesses if I know what the pass does. If it's an inter-procedural analysis pass, then it's in LLVMipa. If it's something to do with code generation, then it's probably in LLVMCodeGen. There's a list of the libraries at http://llvm.org/docs/UsingLibraries.html#descriptions.

2) If that doesn't work, I use xargs/grep to search the source base for the class's implementation. I then look at the Makefile in the same directory to figure out which library it's being compiled into.

I know this may not seem convenient, but it actually works pretty well, and the longer you work with LLVM, the easier it gets.

-- John T.