我是Linux新手,並通過一些clang教程工作。但是,我發現即使是一個簡單的文件也很難編譯。所以,這裏是部分代碼:用以下命令如何用clang/LLVM庫編譯C++代碼?
#include <cstdio>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <utility>
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TargetOptions.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Parse/ParseAST.h"
#include "clang/Rewrite/Core/Rewriter.h"
#include "clang/Rewrite/Frontend/Rewriters.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/raw_ostream.h"
using namespace clang;
using namespace std;
當我試圖編譯簡單的代碼(比方說PrintFunctions.cpp):
clang++ -o PrintFunctions PrintFunctions.cpp
,我得到的錯誤:
fatal error: 'clang/AST/ASTConsumer.h' file not found
嗯,我已經檢查了我的LLVM和鐺已經安裝好,並且文件「鐺/ AST/ASTConsumer.h」是
下找到/usr/lib/llvm-3.4/include/clang/AST
所以,一定有一些我錯過了命令。我不知道該怎麼做......我已經在線閱讀了一些教程,其中大部分都使用了makefile,而且它們似乎很複雜。 那麼,如何編譯它呢?如何找到一個更簡單的方法來編寫makefile?
順便說一句,我在Ubuntu 14.04下,並且clang/LLVM版本是3.4。
LLVM 3.5+還附帶了可用於鏈接的'--system-libs'。 – Thomas
@Thomas:是的,沒錯。 –