gpt4 book ai didi

c++ - 错误#include'ing

转载 作者:行者123 更新时间:2023-11-30 01:19:26 25 4
gpt4 key购买 nike

我试图在 C++ 程序中使用 unordered_map,但每次我收到错误:boost/unordered_map.hpp: No such file or directory

当我第一次收到这个错误时,我正在使用 Mac OS X 10.8.5,我想知道我的编译器是否不符合最新的 C++ 标准。我已经升级到 Mavericks 10.9.1,并且更新了命令行工具。

我还安装了 Boost 库。不过,原始的 unordered_map 似乎不是 Boost 库实现,如果可能的话,我更愿意使用标准。

当尝试正常编译时,没有 Boost,我的#include 和命令行工作正常,除了 unordered_map 的问题:

#include <unordered_map>

g++ -g -Wall testGame.cpp ../card2.cpp ../euchreDeck.cpp -I..

尝试使用 Boost 进行编译时,我尝试了两个单独的命令行,但都没有成功:

#include <boost/unordered_map.hpp>

g++ -g -Wall testGame.cpp ../card2.cpp ../euchreDeck.cpp -I.. -Iboost_1_55_0
g++ -g -Wall testGame.cpp ../card2.cpp ../euchreDeck.cpp -I.. -lboost_1_55_0

这是库链接不正确的问题,我的#include 语句不正确,还是我遗漏了一些明显的东西?

感谢您的帮助。

最佳答案

对于boost,编译器很可能找不到库,因为boost 不在搜索路径中。

对于std,您必须使用-std=c++11,因为unordered_map 是C++11 的特性。

关于c++ - 错误#include'ing <unordered_map>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20892358/

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