Pretty mysterious linking error:
1 | Compiler: Default compiler |
2 | Building Makefile: "C:\DevCpp\Programmi\ctris\Makefile.win" |
3 | Executing make... |
4 | make.exe -f "C:\DevCpp\Programmi\ctris\Makefile.win" all |
5 | gcc.exe -c gfx_misc.cpp -o gfx_misc.o -I"C:/DevCpp/include" -O3 |
6 | |
7 | gcc.exe main.o resources.o timer.o gfx.o board.o gfx_misc.o -o "ctris.exe" -L"C:/DevCpp/lib" -lfblend -lalleg |
8 | |
9 | gfx_misc.o(.text+0xaf):gfx_misc.cpp: undefined reference to `operator delete(void*)' |
10 | gfx_misc.o(.text+0xbb):gfx_misc.cpp: undefined reference to `operator delete(void*)' |
11 | gfx_misc.o(.text+0xeb):gfx_misc.cpp: undefined reference to `__gxx_personality_sj0' |
12 | gfx_misc.o(.text+0x114):gfx_misc.cpp: undefined reference to `operator new(unsigned int)' |
13 | gfx_misc.o(.text+0x222):gfx_misc.cpp: undefined reference to `operator delete(void*)' |
14 | gfx_misc.o(.text+0x22d):gfx_misc.cpp: undefined reference to `operator delete(void*)' |
15 | |
16 | gfx_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)' |
17 | gfx_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*)' |
18 | collect2: ld returned 1 exit status |
19 | |
20 | make.exe: *** [ctris.exe] Error 1 |
21 | |
22 | Execution terminated |
And this is the snipped-down code that generates the error:
1 | class 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 | |
16 | class 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...
Use gpp.exe instead of gcc.exe.
err... stupid IDE why on earth did it choose to use gcc?
thanks!
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]