I've been compiling a very simple 'hello, world' program on a ubuntu 14.04 but failed strangely. The problem is I can't compile a simple hello world program with option -std=c++11.
#include<iostream>
int main(void){
std::cout << “hello, world!” << std::endl;
return 0;
}
I have tried g++ version 4.8.4, 4.9.3, 5.3.0, and clang++ version 3.4. When I compile it with the commands like g++-5 -o main main.cpp -std=c++11, they all failed with the same errors :(this example is generated by 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;
^
But if I compile it with this command: clang++ -o main main.cpp -std=c++11 -stdlib=libc++, everything goes fine. So I suspect there must be some issue with my libstdc++ related headers. Currently I have the following packages installed (generated with 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
I found this same issue here:‘::at_quick_exit’ has not been declared
The third reply of it says "at_quick_exit is ifdefed using _GLIBCXX_HAVE_AT_QUICK_EXIT, perhaps your c library doesn't support it." I think he's right, but I don't know how to solve this problem. Could anybody help?