Easy code generating complex errors (with vector and delete)

[b][red]This message was edited by IDK at 2006-10-19 12:30:42[/red][/b][hr]
I like gcc, but its error messages are very vauge (atlest to me, the creators of gcc would surelly find them very precice).

This is my gcc output:
[code]
neuron.o: In function `__gnu_cxx::new_allocator::deallocate(Neuron**, unsigned int)':
neuron.cpp:(.text._ZN9__gnu_cxx13new_allocatorIP6NeuronE10deallocateEPS2_j[__gnu_cxx::new_allocator::deallocate(Neuron**, unsigned int)]+0xd): undefined reference to `operator delete(void*)'
neuron.o: In function `std::vector >::_M_range_check(unsigned int) const':
neuron.cpp:(.text._ZNKSt6vectorIP6NeuronSaIS1_EE14_M_range_checkEj[std::vector >::_M_range_check(unsigned int) const]+0x23): undefined reference to `std::__throw_out_of_range(char const*)'
neuron.o:(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
[/code]

and here's my code:
[code]
#include

class Neuron{
std::vector Input;
double output;

Neuron();
~Neuron();

double operator [](int index);
};

Neuron::Neuron(){
}
Neuron::~Neuron(){
}

double Neuron::operator [](int index){
return Input.at(index)->output;
}

int main(){
return 0;
}
[/code]

Find any errors?


Comments

  • : [b][red]This message was edited by IDK at 2006-10-19 12:30:42[/red][/b][hr]
    : I like gcc, but its error messages are very vauge (atlest to me, the creators of gcc would surelly find them very precice).
    :
    : This is my gcc output:
    : [code]
    : neuron.o: In function `__gnu_cxx::new_allocator::deallocate(Neuron**, unsigned int)':
    : neuron.cpp:(.text._ZN9__gnu_cxx13new_allocatorIP6NeuronE10deallocateEPS2_j[__gnu_cxx::new_allocator::deallocate(Neuron**, unsigned int)]+0xd): undefined reference to `operator delete(void*)'
    : neuron.o: In function `std::vector >::_M_range_check(unsigned int) const':
    : neuron.cpp:(.text._ZNKSt6vectorIP6NeuronSaIS1_EE14_M_range_checkEj[std::vector >::_M_range_check(unsigned int) const]+0x23): undefined reference to `std::__throw_out_of_range(char const*)'
    : neuron.o:(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
    : collect2: ld returned 1 exit status
    : [/code]
    :
    : and here's my code:
    : [code]
    : #include
    :
    : class Neuron{
    : std::vector Input;
    : double output;
    :
    : Neuron();
    : ~Neuron();
    :
    : double operator [](int index);
    : };
    :
    : Neuron::Neuron(){
    : }
    : Neuron::~Neuron(){
    : }
    :
    : double Neuron::operator [](int index){
    : return Input.at(index)->output;
    : }
    :
    : int main(){
    : return 0;
    : }
    : [/code]
    :
    : Find any errors?
    :
    :
    :
    [purple]u r making constructor and destructor private. may be that caused the errors above.
    [/purple]
    [hr][purple]~Donotalo()[/purple]

  • : : [b][red]This message was edited by IDK at 2006-10-19 12:30:42[/red][/b][hr]
    : : I like gcc, but its error messages are very vauge (atlest to me, the creators of gcc would surelly find them very precice).
    : :
    : : This is my gcc output:
    : : [code]
    : : neuron.o: In function `__gnu_cxx::new_allocator::deallocate(Neuron**, unsigned int)':
    : : neuron.cpp:(.text._ZN9__gnu_cxx13new_allocatorIP6NeuronE10deallocateEPS2_j[__gnu_cxx::new_allocator::deallocate(Neuron**, unsigned int)]+0xd): undefined reference to `operator delete(void*)'
    : : neuron.o: In function `std::vector >::_M_range_check(unsigned int) const':
    : : neuron.cpp:(.text._ZNKSt6vectorIP6NeuronSaIS1_EE14_M_range_checkEj[std::vector >::_M_range_check(unsigned int) const]+0x23): undefined reference to `std::__throw_out_of_range(char const*)'
    : : neuron.o:(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
    : : collect2: ld returned 1 exit status
    : : [/code]
    : :
    : : and here's my code:
    : : [code]
    : : #include
    : :
    : : class Neuron{
    : : std::vector Input;
    : : double output;
    : :
    : : Neuron();
    : : ~Neuron();
    : :
    : : double operator [](int index);
    : : };
    : :
    : : Neuron::Neuron(){
    : : }
    : : Neuron::~Neuron(){
    : : }
    : :
    : : double Neuron::operator [](int index){
    : : return Input.at(index)->output;
    : : }
    : :
    : : int main(){
    : : return 0;
    : : }
    : : [/code]
    : :
    : : Find any errors?
    : :
    : :
    : :
    : [purple]u r making constructor and destructor private. may be that caused the errors above.
    : [/purple]
    : [hr][purple]~Donotalo()[/purple]
    :
    :

    OK, I made it public and now my class definition looks like this:
    [code]
    class Neuron{
    std::vector Input;
    double output;

    public:
    Neuron();
    ~Neuron();

    double operator [](int index);
    };
    [/code]

    But I still get:
    [code]
    neuron.cpp:(.text._ZNKSt6vectorIP6NeuronSaIS1_EE14_M_range_checkEj[std::vector >::_M_range_check(unsigned int) const]+0x23): undefined reference to `std::__throw_out_of_range(char const*)'
    neuron.o: In function `__gnu_cxx::new_allocator::deallocate(Neuron**, unsigned int)':
    neuron.cpp:(.text._ZN9__gnu_cxx13new_allocatorIP6NeuronE10deallocateEPS2_j[__gnu_cxx::new_allocator::deallocate(Neuron**, unsigned int)]+0xd): undefined reference to `operator delete(void*)'
    neuron.o:(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
    [/code]
  • OK, I found the sullotion!!!

    It's simple, I compiled with gcc when I should've compiled with g++, but according to the gcc manual it should take care of that, but it was the linking proccess that was wrong, so they maybe forgot to make it work here or something.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories