::启用了c ++ 11时出现at_quick_exit错误

时间:2016-03-11 02:10:16

标签: c++ c++11 g++ clang++

我一直在编写一个非常简单的问候世界'程序在ubuntu 14.04但奇怪地失败了。问题是我无法使用选项-std = c ++ 11编译一个简单的hello world程序。

#include<iostream>

int main(void){
  std::cout << “hello, world!” << std::endl;
  return 0;
}

我试过g ++版本4.8.4,4.9.3,5.3.0和clang ++ 3.4版。当我用g++-5 -o main main.cpp -std=c++11这样的命令编译它们时,它们都失败并出现相同的错误:(这个例子是由g ++ - 5生成的)

In file included from /usr/include/c++/5/ext/string_conversions.h:41:0,
                 from /usr/include/c++/5/bits/basic_string.h:5251,
                 from /usr/include/c++/5/string:52,
                 from /usr/include/c++/5/bits/locale_classes.h:40,
                 from /usr/include/c++/5/bits/ios_base.h:41,
                 from /usr/include/c++/5/ios:42,
                 from /usr/include/c++/5/ostream:38,
                 from /usr/include/c++/5/iostream:39,
                 from main.cpp:1:
/usr/include/c++/5/cstdlib:126:11: error: ‘::at_quick_exit’ has not been declared
   using ::at_quick_exit;
           ^
/usr/include/c++/5/cstdlib:149:11: error: ‘::quick_exit’ has not been declared
   using ::quick_exit;
           ^

但是如果我用这个命令编译它:clang++ -o main main.cpp -std=c++11 -stdlib=libc++,一切都很顺利。所以我怀疑我的libstdc ++相关标题肯定存在问题。目前我安装了以下软件包(使用dpkg -l | grep libstdc++生成):

ii  libstdc++-4.8-dev:amd64                               4.8.5-2ubuntu1~14.04.1                              amd64        GNU Standard C++ Library v3 (development files)
ii  libstdc++-4.9-dev:amd64                               4.9.3-8ubuntu2~14.04                                amd64        GNU Standard C++ Library v3 (development files)
ii  libstdc++-5-dev:amd64                                 5.3.0-3ubuntu1~14.04                                amd64        GNU Standard C++ Library v3 (development files)
ii  libstdc++6:amd64                                      5.3.0-3ubuntu1~14.04                                amd64        GNU Standard C++ Library v3
ii  libstdc++6:i386                                       5.3.0-3ubuntu1~14.04                                i386         GNU Standard C++ Library v3

我在这里发现了同样的问题:‘::at_quick_exit’ has not been declared 它的第三个回复是&#34; at_quick_exit ifdefed使用_GLIBCXX_HAVE_AT_QUICK_EXIT,也许你的c库不支持它。&#34;我认为他是对的,但我不知道如何解决这个问题。有人可以帮忙吗?

0 个答案:

没有答案