Note that there are some explanatory texts on larger screens.

plurals
  1. POLinking against clang-llvm
    text
    copied!<p>I've been working on a small tool with clang/llvm but I haven't been able to successfully get g++ and gnu's linker to properly link my code against clang.</p> <p>my linker is generating the following errors:</p> <pre><code>undefined reference to `clang::FileManager::~FileManager()' undefined reference to `clang::FileManager::FileManager()' undefined reference to `llvm::sys::getHostTriple()' undefined reference to `clang::Diagnostic::Diagnostic(clang::DiagnosticClient*)' undefined reference to `llvm::outs()' undefined reference to `clang::TargetInfo::CreateTargetInfo(clang::Diagnostic&amp;, clang::TargetOptions&amp;)' undefined reference to `clang::SourceManager::getOrCreateContentCache(clang::FileEntry const*)' undefined reference to `clang::SourceManager::createFileID(clang::SrcMgr::ContentCache const*, clang::SourceLocation, clang::SrcMgr::CharacteristicKind, unsigned int, unsigned int)' </code></pre> <p>my compile commands looks like this:</p> <pre><code>g++ -g -fno-rtti -I~/llvm-2.8/tools/clang-2.8/include \ -I~/llvm-2.8/llvm/include \ `~/bin/llvm-config --cxxflags` \ -c Frontend.cpp g++ -g -fno-rtti -I~/llvm-2.8/tools/clang-2.8/include \ -I~/llvm-2.8/llvm/include \ `~/bin/llvm-config --cxxflags` \ -c exec.cpp g++ -I~/llvm-2.8/tools/clang-2.8/include \ -I~/llvm-2.8/llvm/include -L~/opt/lib/ \ -g -fno-rtti -lclangDriver -lclangAnalysis \ -lclangFrontend -lclangSema -lclangAST -lclangParse \ -lclangLex -lclangBasic \ `~/bin/llvm-config --cxxflags --ldflags --libs` \ Frontend.o exec.o -o run </code></pre> <p>any tips or advice would be welcomed.</p> <p>cheers, ct</p> <p>PS: I've been exploring some of the information on this page:</p> <p><a href="http://ubuntuforums.org/showthread.php?t=532693" rel="nofollow">http://ubuntuforums.org/showthread.php?t=532693</a></p> <p>and it might do the trick, will post a comment on that tip when I can.</p> <h2>Solution</h2> <p>using clang code from this tutorial (which had to be modified to remove the references to FileSystemOptions b/c clang/Basic/FileSystemOptions.h doesn't exist in clang-2.8): <a href="http://clangtutorial.codeplex.com/" rel="nofollow">http://clangtutorial.codeplex.com/</a></p> <pre><code>g++ tutorial1.cpp -g -fno-rtti -lclangFrontend -lclangDriver \ -lclangCodeGen -lclangSema -lclangChecker -lclangAnalysis \ -lclangRewrite -lclangAST -lclangParse -lclangLex -lclangBasic \ -lLLVMSupport -lLLVMSystem -I~/opt/include/ \ `llvm-config --cxxflags --ldflags --libs all` </code></pre> <p>seemed to do the trick!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload