我是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:是的,没错。 –