开发者

Clang / LLVM Header Include Issue (Ubuntu)

I'm working on getting LLVM and clang installed with Ubuntu and try to compile some tutorial code from here - http://www.cs.bgu.ac.il/~mirskyil/CsWiki/Blogs/Post_Mirskyil_4c83cc1f85da2

I have been running into some problems when compiling using g++ and I would assume it is to do with the fact I have not installed something correctly (I am fairly new to this stuff).

When I attempt to execute this command -

g++ tut.cpp -g -o tut.out \
`$LLVM/Debug+Asserts/bin/llvm-config --cxxflags` \
-I$LLVM/tools/clang/include/ \
-lclangFrontendTool -lclangFrontend -lclangDriver -lclangSerialization \
-lclangCodeGen -lclangParse -lclangSema -lclangChecker -lclangAnalysis \
-lclangIndex -lclangRewrite -lclangAST -lclangLex -lclangBasic \
`$LLVM/Debug+Asserts/bin/llvm-config --ldf开发者_开发技巧lags --libs`

I receive the following errors -

/home/rob/llvm/include/llvm/Support/DataTypes.h:45:3: error: #error "Must #define      __STDC_LIMIT_MACROS before #including System/DataTypes.h"

/home/rob/llvm/include/llvm/Support/DataTypes.h:49:3: error: #error "Must #define __STDC_CONSTANT_MACROS before " "#including System/DataTypes.h"

In file included from /llvm/tools/clang/include/clang/AST/Decl.h:17:0,
                 from /llvm/tools/clang/include/clang/AST/ASTContext.h:23,
                 from tut.cpp:3:
/llvm/tools/clang/include/clang/AST/APValue.h:18:29: fatal error: llvm/ADT/APSInt.h: No such file or directory
compilation terminated.

I assume the first error about __STDC_LIMIT_MACROS is I haven't defined something in the command line, but the other error is to do with file includes. It seems that the code is trying to look into 'llvm/APT/APSInt.h' which does not exist, I can manually change these paths to work but it seems like I have done something wrong.

If anyone can point me in the right direction it would be greatly appreciated!


Move tut.cpp to the end of cmdline and you're done.


I think that first you should try to solve the problem with the macro __STDC_LIMIT_MACROS first, When I have this type of error, it 's because I have forgotten this :

llvm-config --cxxflags

You should try to see if this command return what expected:

-I/usr/include  -DNDEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -O3 -fomit-frame-pointer -fvisibility-inlines-hidden -fno-exceptions -fPIC -Woverloaded-virtual -Wcast-qual

For example.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜