gpt4 book ai didi

c++ - 是什么导致 clang 找不到 unordered_map header ?

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:37:40 24 4
gpt4 key购买 nike

我正在尝试使用 Clang++ 编译我在网上找到的程序。 Makefile 生成此命令:

clang++ -c -arch x86_64 -msse3 -std=c++11 -stdlib=libstdc++
-Wno-missing-field-initializers -Wno-missing-prototypes -Wreturn-type
-Wno-non-virtual-dtor -Wno-exit-time-destructors -Wformat -Wmissing-braces
-Wparentheses -Wno-switch -Wunused-function -Wunused-label -Wno-unused-parameter
-Wunused-variable -Wunused-value -Wno-empty-body -Wuninitialized -Wunknown-pragmas
-Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion
-Wint-conversion -Wno-shorten-64-to-32 -Wenum-conversion -Wno-newline-eof
-Wno-c++11-extensions -Wno-logical-op-parentheses -Wno-trigraphs
-Wno-invalid-offsetof -Wno-sign-conversion -Wdeprecated-declarations
-fmessage-length=0 -fno-exceptions -fstrict-aliasing -fvisibility=hidden
-fvisibility-inlines-hidden -funsafe-math-optimizations -ftrapping-math -fno-rtti
-fpascal-strings -fasm-blocks -O3 -Iinclude/ src/main.cpp

但是我明白了

src/main.cpp:23:10: fatal error: 'unordered_map' file not found
#include <unordered_map>
^
1 error generated.

如果我编译一个包含 <unordered_map> 的简单程序运行 clang++ test.cpp ,它编译良好

我在

Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.3.0
Thread model: posix

最佳答案

我在编译 glogg 时遇到了同样的问题。

正如评论所指出的那样。它是标准库。

在运行 qmake 后的 makefile 中。将这一行从

CXXFLAGS      = -g -Wextra -std=c++11 -DGLOGG_VERSION=\"`cat .tarball-version`\" -O2 -arch x86_64 -Wall -W $(DEFINES)

到下面这一行

CXXFLAGS      = -g -Wextra -std=c++11 -stdlib=libc++ -DGLOGG_VERSION=\"`cat .tarball-version`\" -O2 -arch x86_64 -Wall -W $(DEFINES)

注意在 cxxflags 中指定了“-stdlib=libc++”。它在链接器标志中自动指定,我想它也需要在 C++ 标志中指定。

关于c++ - 是什么导致 clang 找不到 unordered_map header ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26233011/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com