[cfe-dev] Undefined reference when linking to clang libraries

Alex Miller millerdevel at gmail.com
Mon Jun 20 11:33:18 PDT 2011


I'm developing off of tags/RELEASE_29/final. During the linking phase of
compiling my program, I get an error that a function inside of one of
clang's libraries has an undefined reference to another function in one of
clang's libraries. I copied the command line invocation of g++ off of a
previous email to this list, so I'm hoping it's correct.

Invocation and error:
$ LLVM=~/workspace/llvm/Debug
$ g++ `$LLVM/bin/llvm-config --cxxflags --ldflags` instmem.cpp
-lclangFrontend -lclangDriver -lclangSerialization -lclangParse -lclangSema
-lclangAnalysis -lclangAST -lclangLex -lclangBasic `$LLVM/bin/llvm-config
--libs` -o instmem
/home/alexander/workspace/llvm/Debug/lib/libclangSerialization.a(ASTReader.o):
In function
`clang::PCHValidator::ReadPredefinesBuffer(llvm::SmallVector<clang::PCHPredefinesBlock,
2u> const&, llvm::StringRef, std::basic_string<char, std::char_traits<char>,
std::allocator<char> >&, clang::FileManager&)':
/home/alexander/workspace/llvm/tools/clang/lib/Serialization/ASTReader.cpp:256:
undefined reference to `clang::NormalizeDashIncludePath(llvm::StringRef,
clang::FileManager&)'
collect2: ld returned 1 exit status

Source:
#include <clang/Frontend/CompilerInvocation.h>
#include <clang/Basic/DiagnosticIDs.h>

int main(int argc, char *argv[])
{
  clang::CompilerInvocation invocation;
  llvm::IntrusiveRefCntPtr<clang::DiagnosticIDs> DiagID(new
clang::DiagnosticIDs());
  clang::Diagnostic Diags(DiagID);

  clang::CompilerInvocation::CreateFromArgs(invocation, argv, argv+argc,
Diags);

  return 0;
}

If anyone could tell me where I'm messing up, I'd appreciate it.

Thanks,
Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110620/a772ef1f/attachment.html>


More information about the cfe-dev mailing list