[cfe-dev] Issue with installation of Clang

Shashank Melkote smelkote at fla.fujitsu.com
Thu Aug 19 15:13:38 PDT 2010


  Hi,

I am new to LLVM and Clang. I am trying to set up Clang on my system. I
am currently running it on Ubuntu 10.04 which is loaded on a VM.

After Installation I tried running a small code to check if it works

this is my code

#include <iostream>

#include <llvm/Support/raw_ostream.h>

#include <clang/Basic/Diagnostic.h>
#include <clang/Basic/TargetInfo.h>
#include <clang/Basic/FileManager.h>
#include <clang/Lex/Preprocessor.h>
#include <clang/Lex/HeaderSearch.h>
#include <clang/Frontend/TextDiagnosticPrinter.h>
#include <clang/Frontend/DiagnosticOptions.h>

using namespace clang;

int main()
{
     llvm::raw_stdout_ostream ost;

     DiagnosticOptions dops;
     TextDiagnosticPrinter tdp(ost,dops);

     return 0;
}

when I run this bit of code using
g++ tut1.cpp -g -fno-rtti `llvm-config --cxxflags --ldflags --libs`
-L/usr/local/lib -lclangBasic -lclangLex -lclangDriver -lclangFrontend
-lclangParse -lclangAST -lclangSema -lclangAnalysis

this is the output that I get

fla at ubuntu:~/Desktop/Clang$ g++ tut1.cpp -g -fno-rtti `llvm-config
--cxxflags --ldflags --libs` -L/usr/local/lib -lclangBasic -lclangLex
-lclangDriver -lclangFrontend -lclangParse -lclangAST -lclangSema
-lclangAnalysis
/usr/local/lib/libclangFrontend.a(TextDiagnosticPrinter.o): In function
`~TextDiagnosticPrinter':
/home/fla/llvm/tools/clang/lib/Frontend/TextDiagnosticPrinter.cpp:53:
undefined reference to `clang::DiagnosticClient::~DiagnosticClient()'
/home/fla/llvm/tools/clang/lib/Frontend/TextDiagnosticPrinter.cpp:53:
undefined reference to `clang::DiagnosticClient::~DiagnosticClient()'
/home/fla/llvm/tools/clang/lib/Frontend/TextDiagnosticPrinter.cpp:53:
undefined reference to `clang::DiagnosticClient::~DiagnosticClient()'
/usr/local/lib/libclangFrontend.a(TextDiagnosticPrinter.o): In function
`clang::TextDiagnosticPrinter::PrintIncludeStack(clang::SourceLocation,
clang::SourceManager const&)':
/home/fla/llvm/tools/clang/lib/Frontend/TextDiagnosticPrinter.cpp:59:
undefined reference to
`clang::SourceManager::getPresumedLoc(clang::SourceLocation) const'
/usr/local/lib/libclangFrontend.a(TextDiagnosticPrinter.o): In function
`clang::TextDiagnosticPrinter::HighlightRange(clang::CharSourceRange
const&, clang::SourceManager const&, unsigned int, clang::FileID,
std::basic_string<char, std::char_traits<char>, std::allocator<char> >&,
std::basic_string<char, std::char_traits<char>, std::allocator<char> >
const&)':
/home/fla/llvm/tools/clang/lib/Frontend/TextDiagnosticPrinter.cpp:91:
undefined reference to
`clang::SourceManager::getInstantiationRange(clang::SourceLocation) const'
/home/fla/llvm/tools/clang/lib/Frontend/TextDiagnosticPrinter.cpp:93:
undefined reference to
`clang::SourceManager::getInstantiationLineNumber(clang::SourceLocation,
bool*) const'
/home/fla/llvm/tools/clang/lib/Frontend/TextDiagnosticPrinter.cpp:97:
undefined reference to
`clang::SourceManager::getInstantiationLineNumber(clang::SourceLocation,
bool*) const'
/home/fla/llvm/tools/clang/lib/Frontend/TextDiagnosticPrinter.cpp:104:
undefined reference to
`clang::SourceManager::getInstantiationColumnNumber(clang::SourceLocation,
bool*) const'
/home/fla/llvm/tools/clang/lib/Frontend/TextDiagnosticPrinter.cpp:111:
undefined reference to
`clang::SourceManager::getInstantiationColumnNumber(clang::SourceLocation,
bool*) const'
/home/fla/llvm/tools/clang/lib/Frontend/TextDiagnosticPrinter.cpp:118:
undefined reference to
`clang::Lexer::MeasureTokenLength(clang::SourceLocation,
clang::SourceManager const&, clang::LangOptions const&)'
/usr/local/lib/libclangFrontend.a(TextDiagnosticPrinter.o): In function
`clang::TextDiagnosticPrinter::EmitCaretDiagnostic(clang::SourceLocation, clang::CharSourceRange*,
unsigned int, clang::SourceManager const&, clang::FixItHint const*,
unsigned int, unsigned int, unsigned int, unsigned int, unsigned int)':
/home/fla/llvm/tools/clang/lib/Frontend/TextDiagnosticPrinter.cpp:310:
undefined reference to
`clang::SourceManager::getImmediateInstantiationRange(clang::SourceLocation)
const'
/home/fla/llvm/tools/clang/lib/Frontend/TextDiagnosticPrinter.cpp:316:
undefined reference to
`clang::SourceManager::getImmediateSpellingLoc(clang::SourceLocation) const'
/home/fla/llvm/tools/clang/lib/Frontend/TextDiagnosticPrinter.cpp:323:
undefined reference to
`clang::SourceManager::getImmediateSpellingLoc(clang::SourceLocation) const'
/home/fla/llvm/tools/clang/lib/Frontend/TextDiagnosticPrinter.cpp:325:
undefined reference to
`clang::SourceManager::getImmediateSpellingLoc(clang::SourceLocation) const'
/home/fla/llvm/tools/clang/lib/Frontend/TextDiagnosticPrinter.cpp:330:
undefined reference to
`clang::SourceManager::getPresumedLoc(clang::SourceLocation) const'
/home/fla/llvm/tools/clang/lib/Frontend/TextDiagnosticPrinter.cpp:370:
undefined reference to
`clang::SourceManager::getBufferData(clang::FileID, bool*) const'
/home/fla/llvm/tools/clang/lib/Frontend/TextDiagnosticPrinter.cpp:374:
undefined reference to
`clang::SourceManager::getColumnNumber(clang::FileID, unsigned int,
bool*) const'
/home/fla/llvm/tools/clang/lib/Frontend/TextDiagnosticPrinter.cpp:376:
undefined reference to
`clang::Lexer::MeasureTokenLength(clang::SourceLocation,
clang::SourceManager const&, clang::LangOptions const&)'
/home/fla/llvm/tools/clang/lib/Frontend/TextDiagnosticPrinter.cpp:403:
undefined reference to
`clang::SourceManager::getLineNumber(clang::FileID, unsigned int, bool*)
const'
/home/fla/llvm/tools/clang/lib/Frontend/TextDiagnosticPrinter.cpp:455:
undefined reference to
`clang::SourceManager::getLineNumber(clang::FileID, unsigned int, bool*)
const'
/home/fla/llvm/tools/clang/lib/Frontend/TextDiagnosticPrinter.cpp:455:
undefined reference to
`clang::SourceManager::getLineNumber(clang::FileID, unsigned int, bool*)
const'
/home/fla/llvm/tools/clang/lib/Frontend/TextDiagnosticPrinter.cpp:460:
undefined reference to
`clang::SourceManager::getColumnNumber(clang::FileID, unsigned int,
bool*) const'
/usr/local/lib/libclangFrontend.a(TextDiagnosticPrinter.o): In function
`clang::TextDiagnosticPrinter::HandleDiagnostic(clang::Diagnostic::Level, clang::DiagnosticInfo
const&)':
/home/fla/llvm/tools/clang/lib/Frontend/TextDiagnosticPrinter.cpp:730:
undefined reference to
`clang::SourceManager::getPresumedLoc(clang::SourceLocation) const'
/home/fla/llvm/tools/clang/lib/Frontend/TextDiagnosticPrinter.cpp:776:
undefined reference to
`clang::SourceManager::getInstantiationRange(clang::SourceLocation) const'
/home/fla/llvm/tools/clang/lib/Frontend/TextDiagnosticPrinter.cpp:789:
undefined reference to
`clang::Lexer::MeasureTokenLength(clang::SourceLocation,
clang::SourceManager const&, clang::LangOptions const&)'
/home/fla/llvm/tools/clang/lib/Frontend/TextDiagnosticPrinter.cpp:794:
undefined reference to
`clang::SourceManager::getColumnNumber(clang::FileID, unsigned int,
bool*) const'
/home/fla/llvm/tools/clang/lib/Frontend/TextDiagnosticPrinter.cpp:794:
undefined reference to
`clang::SourceManager::getLineNumber(clang::FileID, unsigned int, bool*)
const'
/home/fla/llvm/tools/clang/lib/Frontend/TextDiagnosticPrinter.cpp:794:
undefined reference to
`clang::SourceManager::getColumnNumber(clang::FileID, unsigned int,
bool*) const'
/home/fla/llvm/tools/clang/lib/Frontend/TextDiagnosticPrinter.cpp:794:
undefined reference to
`clang::SourceManager::getLineNumber(clang::FileID, unsigned int, bool*)
const'
/usr/local/lib/libclangFrontend.a(TextDiagnosticPrinter.o): In function
`.L498':
/home/fla/llvm/tools/clang/lib/Frontend/TextDiagnosticPrinter.cpp:830:
undefined reference to
`clang::DiagnosticInfo::FormatDiagnostic(llvm::SmallVectorImpl<char>&)
const'
/home/fla/llvm/tools/clang/lib/Frontend/TextDiagnosticPrinter.cpp:834:
undefined reference to
`clang::Diagnostic::getWarningOptionForDiag(unsigned int)'
/home/fla/llvm/tools/clang/lib/Frontend/TextDiagnosticPrinter.cpp:843:
undefined reference to
`clang::Diagnostic::isBuiltinExtensionDiag(unsigned int, bool&)'
/home/fla/llvm/tools/clang/lib/Frontend/TextDiagnosticPrinter.cpp:852:
undefined reference to
`clang::Diagnostic::getCategoryNumberForDiag(unsigned int)'
/home/fla/llvm/tools/clang/lib/Frontend/TextDiagnosticPrinter.cpp:870:
undefined reference to
`clang::Diagnostic::getCategoryNameFromID(unsigned int)'
/home/fla/llvm/tools/clang/lib/Frontend/TextDiagnosticPrinter.cpp:939:
undefined reference to
`clang::SourceManager::getImmediateInstantiationRange(clang::SourceLocation)
const'
/usr/local/lib/libclangFrontend.a(TextDiagnosticPrinter.o): In function
`clang::SourceManager::getFileID(clang::SourceLocation) const':
/home/fla/llvm/tools/clang/lib/Frontend/../../include/clang/Basic/SourceManager.h:571:
undefined reference to `clang::SourceManager::getFileIDSlow(unsigned
int) const'
/usr/local/lib/libclangFrontend.a(TextDiagnosticPrinter.o): In function
`clang::SourceManager::getInstantiationLoc(clang::SourceLocation) const':
/home/fla/llvm/tools/clang/lib/Frontend/../../include/clang/Basic/SourceManager.h:589:
undefined reference to
`clang::SourceManager::getInstantiationLocSlowCase(clang::SourceLocation) const'
/usr/local/lib/libclangFrontend.a(TextDiagnosticPrinter.o): In function
`clang::SourceManager::getDecomposedInstantiationLoc(clang::SourceLocation)
const':
/home/fla/llvm/tools/clang/lib/Frontend/../../include/clang/Basic/SourceManager.h:639:
undefined reference to
`clang::SourceManager::getDecomposedInstantiationLocSlowCase(clang::SrcMgr::SLocEntry
const*, unsigned int) const'
/usr/local/lib/libclangFrontend.a(TextDiagnosticPrinter.o): In function
`DiagnosticClient':
/home/fla/llvm/tools/clang/lib/Frontend/../../include/clang/Basic/Diagnostic.h:976:
undefined reference to `vtable for clang::DiagnosticClient'
/usr/local/lib/libclangFrontend.a(TextDiagnosticPrinter.o):(.data.rel.ro._ZTVN5clang21TextDiagnosticPrinterE[vtable
for clang::TextDiagnosticPrinter]+0x18): undefined reference to
`clang::DiagnosticClient::IncludeInDiagnosticCounts() const'
collect2: ld returned 1 exit status

Their seems to definitely be  some issue regarding linking of the libraries

and the steps used for installation were

svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
cd llvm/tools
svn co http://llvm.org/svn/llvm-project/cfe/trunk clang
cd .. (back to llvm)
./configure
make
(tried make install also)

Could someone help me out with what could be the root cause of this
problem and the possible solution.

Thanks,
Shashank







More information about the cfe-dev mailing list