Clang / LLVM 标头包含问题 (Ubuntu)

发布于 2024-11-29 12:30:57 字数 1531 浏览 0 评论 0原文

我正在努力在 Ubuntu 上安装 LLVM 和 clang,并尝试从这里编译一些教程代码 - http://www.cs.bgu.ac.il/~mirskyil/CsWiki/Blogs/Post_Mirskyil_4c83cc1f85da2

我在使用 g++ 编译时遇到了一些问题,我认为是事实上我没有正确安装某些东西(我对这个东西相当陌生)。

当我尝试执行此命令时 -

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 --ldflags --libs`

我收到以下错误 -

/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.

我假设有关 __STDC_LIMIT_MACROS 的第一个错误是我没有在命令行中定义某些内容,但另一个错误与文件包含有关。代码似乎正在尝试查找不存在的“llvm/APT/APSInt.h”,我可以手动更改这些路径以使其工作,但似乎我做错了一些事情。

如果有人能指出我正确的方向,我将不胜感激!

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 --ldflags --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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

你曾走过我的故事 2024-12-06 12:30:57

将 tut.cpp 移至 cmdline 末尾即可完成。

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

胡渣熟男 2024-12-06 12:30:57

我认为首先你应该尝试先用宏 __STDC_LIMIT_MACROS 来解决问题,
当我遇到这种类型的错误时,是因为我忘记了这一点:

llvm-config --cxxflags

您应该尝试查看此命令是否返回预期的结果:

-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

例如。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文