I need to use a .cpp file which contains #include <unordered_map> in a Qt project (Based on Qt 5.4.2 (Clang 6.0 (Apple), 64 bit)). However, I got the
error: 'unordered_map' file not found. I had checked the path of the folder where unordered_map header file locates is the same as <algorithm>,
<utility>, <iostream>, and <sstream> which are included in the beginning of the same .cpp file. Only 'unordered_map' cannot be found. Any suggestion?
Asked
Active
Viewed 6,222 times
2
Kuba hasn't forgotten Monica
- 95,931
- 16
- 151
- 313
iik
- 73
- 1
- 9
-
2Have you enabled C++11 (or later)? If there's no checkbox in the project settings, manually add the flag `-std=c++11`. – Some programmer dude Aug 29 '15 at 16:04
-
look if https://stackoverflow.com/questions/26233011/what-could-cause-clang-to-not-find-the-unordered-map-header can solve your problem – gengisdave Aug 29 '15 at 16:05
-
Qt provides [QHash](http://doc.qt.io/qt-5/qhash.html#details), I would use it instead `unordered_map`. – Marek R Aug 29 '15 at 17:10
2 Answers
1
The std::unordered_map template class was added in C++11, so you are probably not compiling with C++11 support. This is especially true considering that <algorithm>, <utility>, <iostream> and <sstream> work just fine (which all existed before C++11).
Simply add the -std=c++11 flag while compiling.
Shoe
- 74,840
- 36
- 166
- 272