View previous topic :: View next topic |
Author |
Message |
nrezinorn n00b

Joined: 15 Jul 2004 Posts: 52
|
Posted: Fri Jul 06, 2007 7:44 pm Post subject: gcc won't compile "hello world" |
|
|
I was working on some stuff for work and ran into this snag:
Code: |
/tmp/ccfdjebk.o: In function `__static_initialization_and_destruction_0(int, int)':
filter.cpp:(.text+0x23): undefined reference to `std::ios_base::Init::Init()'
/tmp/ccfdjebk.o: In function `__tcf_0':
filter.cpp:(.text+0x6c): undefined reference to `std::ios_base::Init::~Init()'
/tmp/ccfdjebk.o: In function `main':
filter.cpp:(.text+0x8b): undefined reference to `std::allocator<char>::allocator()'
filter.cpp:(.text+0xa5): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
filter.cpp:(.text+0xb0): undefined reference to `std::allocator<char>::~allocator()'
filter.cpp:(.text+0xe7): undefined reference to `std::cout'
filter.cpp:(.text+0xec): 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*)'
filter.cpp:(.text+0x102): undefined reference to `std::allocator<char>::~allocator()'
filter.cpp:(.text+0x118): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
filter.cpp:(.text+0x123): undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))'
filter.cpp:(.text+0x151): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
filter.cpp:(.text+0x16c): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
/tmp/ccfdjebk.o: In function `void std::_Destroy<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >(std::basic_string<char, std::char_traits<char>, std::allocator<char> >*)':
filter.cpp:(.text._ZSt8_DestroyISsEvPT_[void std::_Destroy<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >(std::basic_string<char, std::char_traits<char>, std::allocator<char> >*)]+0xd): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
|
It's a very basic hello world, it uses <iostream> and cout. It doesn't want to compile. Now the even odder thing, is that my OpenGL/SDL code compiles fine without any errors. It doesn't use <iostream> though, so it sort of appears that iostream doesn't want to work. Or I'm including it wrong. I've tested this on 2 different gentoo systems. Just looking for a push in the right direction. Thanks.
#include <iostream>
using namespace std;
int main () {
cout << "hello world!" << endl;
}
gcc file.cpp -Wall -o test
I'm not compiling as root, if that helps.
-Jim |
|
Back to top |
|
 |
didl Retired Dev


Joined: 09 Sep 2003 Posts: 1106 Location: Pittsburgh, PA
|
Posted: Fri Jul 06, 2007 7:53 pm Post subject: |
|
|
Use g++ not gcc to compile C++ code (to link against the proper
libstdc++). |
|
Back to top |
|
 |
Genone Retired Dev


Joined: 14 Mar 2003 Posts: 9631 Location: beyond the rim
|
Posted: Fri Jul 06, 2007 7:54 pm Post subject: |
|
|
Well, gcc isn't a C++ compiler, use g++ for that. |
|
Back to top |
|
 |
nrezinorn n00b

Joined: 15 Jul 2004 Posts: 52
|
Posted: Fri Jul 06, 2007 8:16 pm Post subject: |
|
|
Thanks for helping me with my n00bness  |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|