gcc/g++ fails to compile
Quoted 6 lines
It is hard to tell what the problem is without sample code and the exact error message along with some details >about your system configuration.
Regards
\Steve
Sorry for the lack of information I hope this makes the situation more clear. I'm using Ubuntu Linux 8.04 and every current stable patch kernel wise. GCC is version 4.3 Remaining info is as follows.
//Sample Code
#include<iostream>
using namespace std;
int main() {
cout <<"Hello World";
return 0;
}//Error message copied from terminal
/tmp/ccERz0tv.o:
In function `std::__verify_grouping(char const*, unsigned int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
test.cpp:(.text+0xe):
undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::size() const'
test.cpp:(.text+0x59): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator[](unsigned int) const' test.cpp:(.text+0x97):
undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char>
Quoted 1 line
::operator[](unsigned int) const'
test.cpp:(.text+0xdf):
undefined reference to `std::basic_string<char,
std::char_traits<char>, std::allocator<char>
Quoted 1 line
::operator[](unsigned int) const'
/tmp/ccERz0tv.o: In function `main':
test.cpp:(.text+0x128): undefined reference to `std::cout' test.cpp:(.text+0x12d):
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/ccERz0tv.o: In function `__static_initialization_and_destruction_0(int, int)':
test.cpp:(.text+0x15d): undefined reference to std::ios_base::Init::Init()' /tmp/ccERz0tv.o: In function __tcf_0':
test.cpp:(.text+0x1aa): undefined reference to std::ios_base::Init::~Init()' /tmp/ccERz0tv.o:(.eh_frame+0x11): undefined reference to __gxx_personality_v0'
collect2: ld returned 1 exit status
- Phil C
Quoted 25 lines · Phil C
Quoted 8 lines
It is hard to tell what the problem is without sample code and the exact error message along with some details about your system configuration.
Regards
\Steve
Sorry for the lack of information I hope this makes the situation more clear. I'm using Ubuntu Linux 8.04 and every current stable patch kernel wise. GCC is version 4.3 Remaining info is as follows.
//Sample Code
#include<iostream>
using namespace std;int main() { cout <<"Hello World"; return 0; }//Error message copied from terminal
Quoted 8 lines
/tmp/ccERz0tv.o:
In function `std::__verify_grouping(char const*, unsigned int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
test.cpp:(.text+0xe):
undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::size() const'
[more "undefined reference" errors snipped]
For linking, you need to either use "g++" (rather than "gcc"), or explicitly link against the C++ library with "-lstdc++". IOW:
g++ test.cc
or:
gcc test.cc -lstdc++
Signature · 1 line
Glynn Clements <[email protected]>
Quoted 40 lines · Phil C
Quoted 6 lines
It is hard to tell what the problem is without sample code and the exact error message along with some details >about your system configuration.
Regards
\Steve
Sorry for the lack of information I hope this makes the situation more clear. I'm using Ubuntu Linux 8.04 and every current stable patch kernel wise. GCC is version 4.3 Remaining info is as follows.
//Sample Code
#include<iostream>
using namespace std;int main() { cout <<"Hello World"; return 0; }//Error message copied from terminal
/tmp/ccERz0tv.o:
In function `std::__verify_grouping(char const*, unsigned int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
test.cpp:(.text+0xe):
undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::size() const'
test.cpp:(.text+0x59): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator[](unsigned int) const' test.cpp:(.text+0x97):
undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char>Quoted 1 line
::operator[](unsigned int) const'
test.cpp:(.text+0xdf):
undefined reference to `std::basic_string<char,
std::char_traits<char>, std::allocator<char>Quoted 1 line
::operator[](unsigned int) const'
Quoted 14 lines
/tmp/ccERz0tv.o: In function `main':
test.cpp:(.text+0x128): undefined reference to `std::cout' test.cpp:(.text+0x12d):
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/ccERz0tv.o: In function `__static_initialization_and_destruction_0(int, int)':
test.cpp:(.text+0x15d): undefined reference tostd::ios_base::Init::Init()' /tmp/ccERz0tv.o: In function__tcf_0':
test.cpp:(.text+0x1aa): undefined reference tostd::ios_base::Init::~Init()' /tmp/ccERz0tv.o:(.eh_frame+0x11): undefined reference to__gxx_personality_v0'
collect2: ld returned 1 exit status
Try 'sudo apt-get install libstdc++6'.
If that doesn't work please provide the exact command you used to compile.
Kristof