You are not logged in.
hey ho, i tried to write the calculator excample included in the stroustrup 3rd edition,
if i compile i get an error output about 30 lines wich does not make any sense to me and since gcc -Wall exercise -o foo >> bar doesn't write input into bar i don't know how to paste the errors.
well actually a mate compiled the source with the gcc 4.1.3 without any problems/warnings
so can it be that the gcc 4.2 got a problem with the std::map or ought it to be my glib/gcc?
lg
edit: ah &> worked ^^ heres the error:
/tmp/cc3fJIKo.o: In function `std::__verify_grouping(char const*, unsigned int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
exercise.cpp:(.text+0xe): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::size() const'
exercise.cpp:(.text+0x59): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator[](unsigned int) const'
exercise.cpp:(.text+0x97): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator[](unsigned int) const'
exercise.cpp:(.text+0xdf): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator[](unsigned int) const'
/tmp/cc3fJIKo.o: In function `error(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
exercise.cpp:(.text+0x12a): undefined reference to `std::cerr'
exercise.cpp:(.text+0x12f): 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*)'
exercise.cpp:(.text+0x140): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <char, std::char_traits<char>, std::allocator<char> >(std::basic_ostream<char, std::char_traits<char> >&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
exercise.cpp:(.text+0x150): 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/cc3fJIKo.o: In function `__tcf_1':
exercise.cpp:(.text+0x166): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
/tmp/cc3fJIKo.o: In function `__static_initialization_and_destruction_0(int, int)':
exercise.cpp:(.text+0x18d): undefined reference to `std::ios_base::Init::Init()'
exercise.cpp:(.text+0x1b5): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string()'
/tmp/cc3fJIKo.o: In function `__tcf_0':
exercise.cpp:(.text+0x23e): undefined reference to `std::ios_base::Init::~Init()'
/tmp/cc3fJIKo.o: In function `get_token()':
exercise.cpp:(.text+0x259): undefined reference to `std::cin'
exercise.cpp:(.text+0x25e): undefined reference to `std::basic_istream<char, std::char_traits<char> >::get(char&)'
exercise.cpp:(.text+0x272): undefined reference to `std::basic_ios<char, std::char_traits<char> >::operator void*() const'
exercise.cpp:(.text+0x30c): undefined reference to `std::cin'
exercise.cpp:(.text+0x311): undefined reference to `std::basic_istream<char, std::char_traits<char> >::putback(char)'
exercise.cpp:(.text+0x320): undefined reference to `std::cin'
exercise.cpp:(.text+0x325): undefined reference to `std::basic_istream<char, std::char_traits<char> >::operator>>(double&)'
exercise.cpp:(.text+0x36a): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator=(char)'
exercise.cpp:(.text+0x383): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::push_back(char)'
exercise.cpp:(.text+0x391): undefined reference to `std::cin'
exercise.cpp:(.text+0x396): undefined reference to `std::basic_istream<char, std::char_traits<char> >::get(char&)'
exercise.cpp:(.text+0x3aa): undefined reference to `std::basic_ios<char, std::char_traits<char> >::operator void*() const'
exercise.cpp:(.text+0x3e5): undefined reference to `std::cin'
exercise.cpp:(.text+0x3ea): undefined reference to `std::basic_istream<char, std::char_traits<char> >::putback(char)'
exercise.cpp:(.text+0x40c): undefined reference to `std::allocator<char>::allocator()'
exercise.cpp:(.text+0x426): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
exercise.cpp:(.text+0x43e): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
exercise.cpp:(.text+0x451): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
exercise.cpp:(.text+0x461): undefined reference to `std::allocator<char>::~allocator()'
exercise.cpp:(.text+0x486): undefined reference to `std::allocator<char>::~allocator()'
/tmp/cc3fJIKo.o: In function `prim(bool)':
exercise.cpp:(.text+0x581): undefined reference to `std::allocator<char>::allocator()'
exercise.cpp:(.text+0x59b): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
exercise.cpp:(.text+0x5b4): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
exercise.cpp:(.text+0x5c7): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
exercise.cpp:(.text+0x5d7): undefined reference to `std::allocator<char>::~allocator()'
exercise.cpp:(.text+0x5ed): undefined reference to `std::allocator<char>::~allocator()'
exercise.cpp:(.text+0x616): undefined reference to `std::allocator<char>::allocator()'
exercise.cpp:(.text+0x630): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
exercise.cpp:(.text+0x649): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
exercise.cpp:(.text+0x65c): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
exercise.cpp:(.text+0x66c): undefined reference to `std::allocator<char>::~allocator()'
exercise.cpp:(.text+0x67f): undefined reference to `std::allocator<char>::~allocator()'
/tmp/cc3fJIKo.o: In function `term(bool)':
exercise.cpp:(.text+0x718): undefined reference to `std::allocator<char>::allocator()'
exercise.cpp:(.text+0x732): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
exercise.cpp:(.text+0x74b): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
exercise.cpp:(.text+0x75e): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
exercise.cpp:(.text+0x76e): undefined reference to `std::allocator<char>::~allocator()'
exercise.cpp:(.text+0x781): undefined reference to `std::allocator<char>::~allocator()'
/tmp/cc3fJIKo.o: In function `main':
exercise.cpp:(.text+0x81d): undefined reference to `std::allocator<char>::allocator()'
exercise.cpp:(.text+0x837): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
exercise.cpp:(.text+0x85d): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
exercise.cpp:(.text+0x870): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
exercise.cpp:(.text+0x880): undefined reference to `std::allocator<char>::~allocator()'
exercise.cpp:(.text+0x88b): undefined reference to `std::allocator<char>::allocator()'
exercise.cpp:(.text+0x8a5): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
exercise.cpp:(.text+0x8b8): undefined reference to `std::allocator<char>::~allocator()'
exercise.cpp:(.text+0x8ec): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
exercise.cpp:(.text+0x8ff): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
exercise.cpp:(.text+0x90f): undefined reference to `std::allocator<char>::~allocator()'
exercise.cpp:(.text+0x922): undefined reference to `std::allocator<char>::~allocator()'
exercise.cpp:(.text+0x960): undefined reference to `std::cout'
exercise.cpp:(.text+0x965): undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(double)'
exercise.cpp:(.text+0x975): 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)'
exercise.cpp:(.text+0x97c): undefined reference to `std::cin'
exercise.cpp:(.text+0x981): undefined reference to `std::basic_ios<char, std::char_traits<char> >::operator void*() const'
/tmp/cc3fJIKo.o: In function `std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, double>::~pair()':
exercise.cpp:(.text._ZNSt4pairIKSsdED1Ev[std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, double>::~pair()]+0xd): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
/tmp/cc3fJIKo.o: In function `bool std::operator< <char, std::char_traits<char>, std::allocator<char> >(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
exercise.cpp:(.text._ZStltIcSt11char_traitsIcESaIcEEbRKSbIT_T0_T1_ES8_[bool std::operator< <char, std::char_traits<char>, std::allocator<char> >(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)]+0x14): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::compare(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
/tmp/cc3fJIKo.o: In function `__gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, double> > >::deallocate(std::_Rb_tree_node<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, double> >*, unsigned int)':
exercise.cpp:(.text._ZN9__gnu_cxx13new_allocatorISt13_Rb_tree_nodeISt4pairIKSsdEEE10deallocateEPS5_j[__gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, double> > >::deallocate(std::_Rb_tree_node<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, double> >*, unsigned int)]+0xd): undefined reference to `operator delete(void*)'
/tmp/cc3fJIKo.o: In function `std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, double>::pair(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, double const&)':
exercise.cpp:(.text._ZNSt4pairIKSsdEC1ERS0_RKd[std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, double>::pair(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, double const&)]+0x14): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/tmp/cc3fJIKo.o: In function `std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, double>::pair(std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, double> const&)':
exercise.cpp:(.text._ZNSt4pairIKSsdEC1ERKS1_[std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, double>::pair(std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, double> const&)]+0x14): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/tmp/cc3fJIKo.o: In function `std::_Rb_tree_iterator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, double> >::operator--()':
exercise.cpp:(.text._ZNSt17_Rb_tree_iteratorISt4pairIKSsdEEmmEv[std::_Rb_tree_iterator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, double> >::operator--()]+0xf): undefined reference to `std::_Rb_tree_decrement(std::_Rb_tree_node_base*)'
/tmp/cc3fJIKo.o: In function `std::_Rb_tree_iterator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, double> >::operator++()':
exercise.cpp:(.text._ZNSt17_Rb_tree_iteratorISt4pairIKSsdEEppEv[std::_Rb_tree_iterator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, double> >::operator++()]+0xf): undefined reference to `std::_Rb_tree_increment(std::_Rb_tree_node_base*)'
/tmp/cc3fJIKo.o: In function `__gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, double> > >::allocate(unsigned int, void const*)':
exercise.cpp:(.text._ZN9__gnu_cxx13new_allocatorISt13_Rb_tree_nodeISt4pairIKSsdEEE8allocateEjPKv[__gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, double> > >::allocate(unsigned int, void const*)]+0x24): undefined reference to `std::__throw_bad_alloc()'
exercise.cpp:(.text._ZN9__gnu_cxx13new_allocatorISt13_Rb_tree_nodeISt4pairIKSsdEEE8allocateEjPKv[__gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, double> > >::allocate(unsigned int, void const*)]+0x3f): undefined reference to `operator new(unsigned int)'
/tmp/cc3fJIKo.o: In function `std::_Rb_tree<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, double>, std::_Select1st<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, double> >, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, double> > >::_M_create_node(std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, double> const&)':
exercise.cpp:(.text._ZNSt8_Rb_treeISsSt4pairIKSsdESt10_Select1stIS2_ESt4lessISsESaIS2_EE14_M_create_nodeERKS2_[std::_Rb_tree<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, double>, std::_Select1st<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, double> >, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, double> > >::_M_create_node(std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, double> const&)]+0x74): undefined reference to `__cxa_begin_catch'
exercise.cpp:(.text._ZNSt8_Rb_treeISsSt4pairIKSsdESt10_Select1stIS2_ESt4lessISsESaIS2_EE14_M_create_nodeERKS2_[std::_Rb_tree<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, double>, std::_Select1st<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, double> >, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, double> > >::_M_create_node(std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, double> const&)]+0x8b): undefined reference to `__cxa_rethrow'
exercise.cpp:(.text._ZNSt8_Rb_treeISsSt4pairIKSsdESt10_Select1stIS2_ESt4lessISsESaIS2_EE14_M_create_nodeERKS2_[std::_Rb_tree<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, double>, std::_Select1st<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, double> >, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, double> > >::_M_create_node(std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, double> const&)]+0x96): undefined reference to `__cxa_end_catch'
/tmp/cc3fJIKo.o: In function `std::_Rb_tree<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, double>, std::_Select1st<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, double> >, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, double> > >::_M_insert(std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, double> const&)':
exercise.cpp:(.text._ZNSt8_Rb_treeISsSt4pairIKSsdESt10_Select1stIS2_ESt4lessISsESaIS2_EE9_M_insertEPSt18_Rb_tree_node_baseSA_RKS2_[std::_Rb_tree<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, double>, std::_Select1st<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, double> >, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, double> > >::_M_insert(std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, double> const&)]+0xa4): undefined reference to `std::_Rb_tree_insert_and_rebalance(bool, std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::_Rb_tree_node_base&)'
/tmp/cc3fJIKo.o:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit statusLast edited by fingerpicker (2007-07-20 12:31:48)
Offline
How are you compiling it? Looks to be a linker error, meaning it can't find the C++ standard library at link-time.
-edit-
are you sure you are compiling with g++ and not gcc?
I got some errors like that when compiling C++ code with gcc
That would definitely cause linker errors - gcc compiles C code, and g++ compiles C++ code. If you're using gcc it won't pick up the C++ libraries.
Last edited by Cerebral (2007-07-20 13:22:53)
Offline
thanks folks O_o i'm just too dump
you where right i was using the wrong compiler (and thus i tried to compile it bout 20 times O_O)
Offline
Offline