[Bug 1272713] Re: Hello World does not compile with C++11
Andreas Moog
andreas.moog at warperbbs.de
Sat Jan 25 17:25:34 UTC 2014
Thanks for the report. That is expected behaviour, gcc doesn't automatically include link libraries other than for C. You can use either
g++ -std=c++11
or explicitly add the standard c++ library to the command line:
gcc -std=c++11 test.cpp -lstdc++
** Changed in: gcc-defaults (Ubuntu)
Status: New => Invalid
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to gcc-defaults in Ubuntu.
https://bugs.launchpad.net/bugs/1272713
Title:
Hello World does not compile with C++11
Status in “gcc-defaults” package in Ubuntu:
Invalid
Bug description:
The following source code:
#include <iostream>
int main()
{
std::cout << "Hello world\n";
}
compiled with the following line:
$gcc hello.cpp -std=c++11
Produces the following error:
/tmp/ccN5qDSY.o: In function `main':
hello.cpp:(.text+0x14): undefined reference to `std::cout'
hello.cpp:(.text+0x19): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/tmp/ccN5qDSY.o: In function `__static_initialization_and_destruction_0(int, int)':
hello.cpp:(.text+0x41): undefined reference to `std::ios_base::Init::Init()'
hello.cpp:(.text+0x58): undefined reference to `std::ios_base::Init::~Init()'
ProblemType: Bug
DistroRelease: Ubuntu 13.10
Package: gcc 4:4.8.1-2ubuntu3
ProcVersionSignature: Ubuntu 3.11.0-15.23-generic 3.11.10
Uname: Linux 3.11.0-15-generic i686
ApportVersion: 2.12.5-0ubuntu2.2
Architecture: i386
Date: Sat Jan 25 20:52:23 2014
InstallationDate: Installed on 2013-12-22 (34 days ago)
InstallationMedia: Ubuntu 13.10 "Saucy Salamander" - Release i386 (20131016.1)
MarkForUpload: True
SourcePackage: gcc-defaults
UpgradeStatus: No upgrade log present (probably fresh install)
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gcc-defaults/+bug/1272713/+subscriptions
More information about the foundations-bugs
mailing list