[cfe-dev] Switching to clang 2.8

Simone Pellegrini spellegrini at dps.uibk.ac.at
Sat Sep 18 10:37:31 PDT 2010


  Dear all,
I am working on a project where we use clang internally for parsing and 
rewriting capabilities.

I decided to give clang 2.8 a try and replaced the old installation with 
the RC2. I had to make some changes in the code but not big deal, the 
main problem I cannot solve now is the linking.

When I build llvm I use the flag 'clang-only' to build the part I am 
interested in.
I built llvm using the following 2 commands:

./configure --prefix=.. --enable-shared --enable-asserts
make REQUIRES_RTTI=1 clang-only && make install clang-only

In order to feed the clang library to my project I have a cmake file 
where I specify one by one the libraries which has to be linked.
I noticed that libCIndex.a so I updated my cmake file by removing any 
reference to it. Basically this is the list of libraries (from the cmake 
file):

find_library(clang_CompilerDriver_LIB NAMES CompilerDriver     PATHS 
${LLVM_HOME}/lib)
find_library(clang_Basic_LIB           NAMES clangBasic         PATHS 
${LLVM_HOME}/lib)
find_library(clang_Sema_LIB          NAMES clangSema         PATHS 
${LLVM_HOME}/lib)
find_library(clang_CIndex_LIB        NAMES CIndex             PATHS 
${LLVM_HOME}/lib)
find_library(clang_Driver_LIB         NAMES clangDriver     PATHS 
${LLVM_HOME}/lib)
find_library(clang_AST_LIB             NAMES clangAST         PATHS 
${LLVM_HOME}/lib)
find_library(clang_Rewrite_LIB       NAMES clangRewrite     PATHS 
${LLVM_HOME}/lib)
find_library(clang_Analysis_LIB      NAMES clangAnalysis     PATHS 
${LLVM_HOME}/lib)
find_library(clang_Lex_LIB             NAMES clangLex         PATHS 
${LLVM_HOME}/lib)
find_library(clang_Frontend_LIB     NAMES clangFrontend     PATHS 
${LLVM_HOME}/lib)
find_library(clang_Parse_LIB          NAMES clangParse         PATHS 
${LLVM_HOME}/lib)
find_library(clang_Index_LIB          NAMES clangIndex         PATHS 
${LLVM_HOME}/lib)

set(clang_LIBs  ${clang_CompilerDriver_LIB} ${clang_CIndex_LIB} 
${clang_Sema_LIB} ${clang_Driver_LIB} ${clang_AST_LIB} ${clang_Rewrite_LIB}
                 ${clang_Analysis_LIB} ${clang_Lex_LIB} 
${clang_Frontend_LIB} ${clang_Parse_LIB} ${clang_Basic_LIB} 
${clang_Index_LIB})


When I try to compile my project with the new clang I get a linking 
error, it looks like some definitions are missing or perhaps they have 
been moved in another library:

llvm-2.8/lib/libclangAnalysis.a(AnalysisContext.o): In function 
`clang::AnalysisContext::getParentMap()':
llvm-2.8-src/tools/clang/lib/Analysis/AnalysisContext.cpp:83: undefined 
reference to `clang::ParentMap::ParentMap(clang::Stmt*)'
llvm-2.8/lib/libclangAnalysis.a(AnalysisContext.o): In function 
`~AnalysisContext':
llvm-2.8-src/tools/clang/lib/Analysis/AnalysisContext.cpp:338: undefined 
reference to `clang::ParentMap::~ParentMap()'
llvm-2.8-src/tools/clang/lib/Analysis/AnalysisContext.cpp:338: undefined 
reference to `clang::ParentMap::~ParentMap()'
llvm-2.8/lib/libclangFrontend.a(CompilerInstance.o): In function 
`clang::CompilerInstance::createPCHExternalASTSource(llvm::StringRef, 
std::basic_string<char, std::char_traits<char>, std::allocator<char> > 
const&, bool, clang::Preprocessor&, clang::ASTContext&, void*)':
llvm-2.8-src/tools/clang/lib/Frontend/CompilerInstance.cpp:270: 
undefined reference to 
`clang::ASTReader::ASTReader(clang::Preprocessor&, clang::ASTContext*, 
char const*, bool)'
llvm-2.8-src/tools/clang/lib/Frontend/CompilerInstance.cpp:273: 
undefined reference to 
`clang::ASTReader::setDeserializationListener(clang::ASTDeserializationListener*)'
llvm-2.8-src/tools/clang/lib/Frontend/CompilerInstance.cpp:274: 
undefined reference to 
`clang::ASTReader::ReadAST(std::basic_string<char, 
std::char_traits<char>, std::allocator<char> > const&)'
llvm-2.8/lib/libclangFrontend.a(CompilerInstance.o): In function 
`CodeCompleteConsumer':
llvm-2.8-src/tools/clang/lib/Frontend/../../include/clang/Sema/CodeCompleteConsumer.h:719: 
undefined reference to `vtable for clang::CodeCompleteConsumer'
llvm-2.8/lib/libclangFrontend.a(CompilerInstance.o): In function 
`PrintingCodeCompleteConsumer':
llvm-2.8-src/tools/clang/lib/Frontend/../../include/clang/Sema/CodeCompleteConsumer.h:771: 
undefined reference to `vtable for clang::PrintingCodeCompleteConsumer'
llvm-2.8/lib/libclangFrontend.a(CompilerInstance.o): In function 
`CIndexCodeCompleteConsumer':
llvm-2.8-src/tools/clang/lib/Frontend/../../include/clang/Sema/CodeCompleteConsumer.h:797: 
undefined reference to `vtable for clang::CIndexCodeCompleteConsumer'
llvm-2.8/lib/libclangFrontend.a(CompilerInvocation.o): In function 
`ParseAnalyzerArgs':
llvm-2.8-src/tools/clang/lib/Frontend/CompilerInvocation.cpp:762: 
undefined reference to 
`clang::driver::ArgList::getLastArg(clang::driver::OptSpecifier) const'
llvm-2.8-src/tools/clang/lib/Frontend/CompilerInvocation.cpp:772: 
undefined reference to 
`clang::driver::Arg::getAsString(clang::driver::ArgList const&) const'
llvm-2.8-src/tools/clang/lib/Frontend/CompilerInvocation.cpp:777: 
undefined reference to 
`clang::driver::ArgList::getLastArg(clang::driver::OptSpecifier) const'
llvm-2.8-src/tools/clang/lib/Frontend/CompilerInvocation.cpp:787: 
undefined reference to 
`clang::driver::Arg::getAsString(clang::driver::ArgList const&) const'
llvm-2.8-src/tools/clang/lib/Frontend/CompilerInvocation.cpp:792: 
undefined reference to 
`clang::driver::ArgList::getLastArg(clang::driver::OptSpecifier) const'
llvm-2.8-src/tools/clang/lib/Frontend/CompilerInvocation.cpp:802: 
undefined reference to 
`clang::driver::Arg::getAsString(clang::driver::ArgList const&) const'
llvm-2.8-src/tools/clang/lib/Frontend/CompilerInvocation.cpp:815: 
undefined reference to 
`clang::driver::ArgList::getLastArgValue(clang::driver::OptSpecifier, 
llvm::StringRef) const'
llvm-2.8-src/tools/clang/lib/Frontend/CompilerInvocation.cpp:821: 
undefined reference to 
`clang::driver::ArgList::getLastArgIntValue(clang::driver::OptSpecifier, 
int, clang::Diagnostic&) const'
llvm-2.8-src/tools/clang/lib/Frontend/CompilerInvocation.cpp:822: 
undefined reference to 
`clang::driver::ArgList::getLastArgIntValue(clang::driver::OptSpecifier, 
int, clang::Diagnostic&) const'
llvm-2.8/lib/libclangFrontend.a(CompilerInvocation.o): In function 
`ParseCodeGenArgs':
llvm-2.8-src/tools/clang/lib/Frontend/CompilerInvocation.cpp:834: 
undefined reference to 
`clang::driver::ArgList::getLastArgIntValue(clang::driver::OptSpecifier, 
int, clang::Diagnostic&) const'
llvm-2.8-src/tools/clang/lib/Frontend/CompilerInvocation.cpp:837: 
undefined reference to 
`clang::driver::ArgList::getLastArg(clang::driver::OptSpecifier) const'
llvm-2.8-src/tools/clang/lib/Frontend/CompilerInvocation.cpp:837: 
undefined reference to 
`clang::driver::Arg::getAsString(clang::driver::ArgList const&) const'
llvm-2.8-src/tools/clang/lib/Frontend/CompilerInvocation.cpp:849: 
undefined reference to 
`clang::driver::ArgList::getLastArgValue(clang::driver::OptSpecifier, 
llvm::StringRef) const'
llvm-2.8-src/tools/clang/lib/Frontend/CompilerInvocation.cpp:862: 
undefined reference to 
`clang::driver::ArgList::getLastArgValue(clang::driver::OptSpecifier, 
llvm::StringRef) const'
llvm-2.8-src/tools/clang/lib/Frontend/CompilerInvocation.cpp:863: 
undefined reference to 
`clang::driver::ArgList::getLastArgValue(clang::driver::OptSpecifier, 
llvm::StringRef) const'
llvm-2.8-src/tools/clang/lib/Frontend/CompilerInvocation.cpp:865: 
undefined reference to 
`clang::driver::ArgList::getLastArgValue(clang::driver::OptSpecifier, 
llvm::StringRef) const'
llvm-2.8-src/tools/clang/lib/Frontend/CompilerInvocation.cpp:867: 
undefined reference to 
`clang::driver::ArgList::getLastArgValue(clang::driver::OptSpecifier, 
llvm::StringRef) const'
llvm-2.8/lib/libclangFrontend.a(CompilerInvocation.o):/home/motonacciu/software/llvm-2.8-src/tools/clang/lib/Frontend/CompilerInvocation.cpp:873: 
more undefined references to 
`clang::driver::ArgList::getLastArgValue(clang::driver::OptSpecifier, 
llvm::StringRef) const' follow
...

Thanks in advance for the help,
cheers, Simone




More information about the cfe-dev mailing list