Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/140.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ ICPC:;标识符"_节点“分配程序”;是未定义的“;在编译C++;使用带有icpc的std::map的文件_C++_Stl_Undefined Reference_Stdmap_Icc - Fatal编程技术网

C++ ICPC:;标识符"_节点“分配程序”;是未定义的“;在编译C++;使用带有icpc的std::map的文件

C++ ICPC:;标识符"_节点“分配程序”;是未定义的“;在编译C++;使用带有icpc的std::map的文件,c++,stl,undefined-reference,stdmap,icc,C++,Stl,Undefined Reference,Stdmap,Icc,我正在尝试编译以下代码: #include <map> int main() { std::map<double, double> test; return 0; } 我得到以下错误: /usr/include/c++/8/bits/stl_tree.h(700):错误:标识符 “\u节点\u分配器”未定义 _GLIBCXX_不例外_如果( ^ 在实例化“std::_Rb_tree::_Rb_tree_impl::_Rb_tree_impl()[with _

我正在尝试编译以下代码:

#include <map>

int main() {
  std::map<double, double> test;

  return 0;
}
我得到以下错误:

/usr/include/c++/8/bits/stl_tree.h(700):错误:标识符
“\u节点\u分配器”未定义
_GLIBCXX_不例外_如果(
^
在实例化“std::_Rb_tree::_Rb_tree_impl::_Rb_tree_impl()[with _Key=double,_Val=std::pair,_KeyOfValue=std::_Select1st,_Compare=std::less,Alloc=std::allocator,_Key\u Compare=std::less,=true]时检测到”
在“main.cpp”的第6行
还有一些类型特征错误,如:

/usr/include/c++/8/type_traits(921): error: not a class or struct name
      : public __is_default_constructible_atom<_Tp>::type
               ^
          detected during:
            instantiation of class 
"std::__is_default_constructible_safe<_Tp, false> [with _Tp=<error-
type>]" at line 927
            instantiation of class "std::is_default_constructible<_Tp> 
[with _Tp=<error-type>]" at line 144
            instantiation of class "std::__and_<_B1, _B2> [with 
_B1=std::is_default_constructible<<error-type>>, 
_B2=std::__is_nt_default_constructible_impl<<error-type>, false>]" at 
line 995
            instantiation of class 
"std::is_nothrow_default_constructible<_Tp> [with _Tp=<error-type>]" 
at line 700 of "/usr/include/c++/8/bits/stl_tree.h"
            instantiation of "std::_Rb_tree<_Key, _Val, _KeyOfValue, 
_Compare, _Alloc>::_Rb_tree_impl<_Key_compare, 
<unnamed>>::_Rb_tree_impl() [with _Key=double, _Val=std::pair<const 
double, double>, _Key
OfValue=std::_Select1st<std::pair<const double, double>>, 
_Compare=std::less<double>, _Alloc=std::allocator<std::pair<const 
double, double>>, _Key_compare=std::less<double>, <unnamed>=true]" at 
line 6 of "
main.cpp"
所以我的icpc和g++版本是兼容的。我也没有忘记icpc的
compilervars.sh
文件的源代码

我找不到任何有此错误的帖子,也不在英特尔网站上。是否需要添加到icpc的特定库不是自动添加的,以便能够使用
std::map


我尝试在编译命令中添加
-lstdc++
,但没有成功。

问题的答案是:

icc 18.0.3不支持gcc-8,即使使用以下bash命令:

> icpc -v
icpc version 18.0.3 (gcc version 8.1.0 compatibility)
让人觉得是的

icc 18支持gcc 4.3至6.3

为了在不更改默认gcc版本的情况下解决此问题,我执行了以下操作:

/usr/include/c++/8/type_traits(921): error: not a class or struct name
      : public __is_default_constructible_atom<_Tp>::type
               ^
          detected during:
            instantiation of class 
"std::__is_default_constructible_safe<_Tp, false> [with _Tp=<error-
type>]" at line 927
            instantiation of class "std::is_default_constructible<_Tp> 
[with _Tp=<error-type>]" at line 144
            instantiation of class "std::__and_<_B1, _B2> [with 
_B1=std::is_default_constructible<<error-type>>, 
_B2=std::__is_nt_default_constructible_impl<<error-type>, false>]" at 
line 995
            instantiation of class 
"std::is_nothrow_default_constructible<_Tp> [with _Tp=<error-type>]" 
at line 700 of "/usr/include/c++/8/bits/stl_tree.h"
            instantiation of "std::_Rb_tree<_Key, _Val, _KeyOfValue, 
_Compare, _Alloc>::_Rb_tree_impl<_Key_compare, 
<unnamed>>::_Rb_tree_impl() [with _Key=double, _Val=std::pair<const 
double, double>, _Key
OfValue=std::_Select1st<std::pair<const double, double>>, 
_Compare=std::less<double>, _Alloc=std::allocator<std::pair<const 
double, double>>, _Key_compare=std::less<double>, <unnamed>=true]" at 
line 6 of "
main.cpp"
首先,我在我的Ubuntu 16.04机器上安装了gcc 6:

sudo apt-get install gcc-6 g++-6
然后,我将以下标志添加到我的编译器标志中:

-gxx-name=/usr/bin/g++-6
并将include目录的版本从8更改为6:

-I /usr/include/x86_64-linux-gnu/c++/6

也许你需要指定你要使用的C++标准:<代码> -STD= C++ 17 < /COD>example@OlivierSohn我尝试了这个,得到了与上面完全相同的错误。我想我明白了,您使用的是
-I/usr/include/x86_64-linux-gnu/c++/8
:然后您还应该指定要使用的标准库的路径,否则您就不是g保证有一个对应于正确版本的选项。顺便说一句,如果您删除了
-I
选项怎么办?@OlivierSohn如果我删除-I选项,我会在/usr/include/c++/8/bits/stl_tree.h(63)、/usr/include/c++/8/map(60)、main.cpp(2)中包含的文件中得到以下结果:/usr/include/c++/8/bits/stl_algobase.h(59):灾难性错误:无法打开源文件“bits/c++config.h”#include^ main.cpp的编译中止(代码4)确定,这看起来相关吗?