Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » [Linker error] undefined reference to `operator delete(void*)'

Credits go to Krzysztof Kluczek for helping out!
This thread is locked; no one can reply to it. rss feed Print
[Linker error] undefined reference to `operator delete(void*)'
FMC
Member #4,431
March 2004
avatar

Pretty mysterious linking error:

1Compiler: Default compiler
2Building Makefile: "C:\DevCpp\Programmi\ctris\Makefile.win"
3Executing make...
4make.exe -f "C:\DevCpp\Programmi\ctris\Makefile.win" all
5gcc.exe -c gfx_misc.cpp -o gfx_misc.o -I"C:/DevCpp/include" -O3
6 
7gcc.exe main.o resources.o timer.o gfx.o board.o gfx_misc.o -o "ctris.exe" -L"C:/DevCpp/lib" -lfblend -lalleg
8 
9gfx_misc.o(.text+0xaf):gfx_misc.cpp: undefined reference to `operator delete(void*)'
10gfx_misc.o(.text+0xbb):gfx_misc.cpp: undefined reference to `operator delete(void*)'
11gfx_misc.o(.text+0xeb):gfx_misc.cpp: undefined reference to `__gxx_personality_sj0'
12gfx_misc.o(.text+0x114):gfx_misc.cpp: undefined reference to `operator new(unsigned int)'
13gfx_misc.o(.text+0x222):gfx_misc.cpp: undefined reference to `operator delete(void*)'
14gfx_misc.o(.text+0x22d):gfx_misc.cpp: undefined reference to `operator delete(void*)'
15 
16gfx_misc.o(.text$_ZNSt6vectorI8particleSaIS0_EE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPS0_S2_EERKS0_[std::vector<particle, std::allocator<particle> >::_M_insert_aux(__gnu_cxx::__normal_iterator<particle*, std::vector<particle, std::allocator<particle> > >, particle const&)]+0x140):gfx_misc.cpp: undefined reference to `operator new(unsigned int)'
17gfx_misc.o(.text$_ZNSt6vectorI8particleSaIS0_EE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPS0_S2_EERKS0_[std::vector<particle, std::allocator<particle> >::_M_insert_aux(__gnu_cxx::__normal_iterator<particle*, std::vector<particle, std::allocator<particle> > >, particle const&)]+0x27f):gfx_misc.cpp: undefined reference to `operator delete(void*)'
18collect2: ld returned 1 exit status
19 
20make.exe: *** [ctris.exe] Error 1
21 
22Execution terminated

And this is the snipped-down code that generates the error:

1class particle{
2 float x,y, vx, vy;
3 int type, life, col, size;
4 public:
5 particle(int t, float _x, float _y){
6 ...
7 }
8 void draw(BITMAP *buf){
9 ...
10 }
11 int update(){
12 ...
13 }
14 };
15
16class ccomet {
17 vector<particle> trail;
18 int x,y;
19 public:
20 ccomet(int a, int b){
21 x = a;
22 y = b;
23 for(int x=0; x<100; x++){
24 trail.push_back(particle(tCOMET, (float)x, (float)y));
25 }
26 }
27 void draw(BITMAP *buf){
28 for(int x=0; x<trail.size(); x++){
29 trail[x].draw(buf);
30 }
31 }
32 void update(){
33 vector<particle>::iterator p;
34 for(p = trail.begin(); p!=trail.end(); p++){
35 if(p->update()){//is dead
36 trail.erase(p);
37 p--;
38 }
39 }
40 }
41 ~ccomet(){
42 trail.empty();
43 }
44
45 }*com;

It actually compiled fine, but as soon as i added com = new ccomet(20,20); that nasty error popped out.
Its been quite some time from the last time i programmed, so it could be something stupid...

[FMC Studios] - [Caries Field] - [Ctris] - [Pman] - [Chess for allegroites]
Written laws are like spiders' webs, and will, like them, only entangle and hold the poor and weak, while the rich and powerful will easily break through them. -Anacharsis
Twenty years from now you will be more disappointed by the things that you didn't do than by the ones you did do. So throw off the bowlines. Sail away from the safe harbor. Catch the trade winds in your sails. Explore. Dream. Discover. -Mark Twain

Krzysztof Kluczek
Member #4,191
January 2004
avatar

Use gpp.exe instead of gcc.exe. :)

FMC
Member #4,431
March 2004
avatar

err... stupid IDE why on earth did it choose to use gcc? :P
thanks!

[FMC Studios] - [Caries Field] - [Ctris] - [Pman] - [Chess for allegroites]
Written laws are like spiders' webs, and will, like them, only entangle and hold the poor and weak, while the rich and powerful will easily break through them. -Anacharsis
Twenty years from now you will be more disappointed by the things that you didn't do than by the ones you did do. So throw off the bowlines. Sail away from the safe harbor. Catch the trade winds in your sails. Explore. Dream. Discover. -Mark Twain

Niunio
Member #1,975
March 2002
avatar

You didn't link the C++ runtime library. Note that it doesn't be included by gcc automaticly. Some gcc compilers named it "libc++" some others (DJGPP if I remember correctly) named it "libcxx" so you must add either "-lc++" or "-lcxx" at the link command.

[edit]Too slow... and gpp includes the C++ runtime library automaticly.[/edit]

-----------------
Current projects: Allegro.pas | KOFFE

Go to: