Code::Blocks building problem-Collection of common programming errors

Hi I have a problem building a program in Code::Blocks. The problem is when I build the code it starts giving me all kind of unrelated errors like these:

main.cpp:(.text+0x12): undefined reference to `system’

main.cpp:(.text+0x1e): undefined reference to `system’

main.cpp:(.text+0x37): undefined reference to `ZSt4cout’

main.cpp:(.text+0x3c): undefined reference to `ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc’

main.cpp:(.text+0x44): undefined reference to `ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_’

main.cpp:(.text+0x4c): undefined reference to `ZNSolsEPFRSoS_E’

main.cpp:(.text+0x5b): undefined reference to `ZSt3cin’

main.cpp:(.text+0x60): undefined reference to `ZNSirsERd’

main.cpp:(.text+0xaf): undefined reference to `ZSt4cout’

main.cpp:(.text+0xb4): undefined reference to `ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc’

main.cpp:(.text+0xc4): undefined reference to `ZNSolsEd’

….and so on

The problem is before I edit the same program in my Ubuntu 11.04 it was running without a problem on Windows 7. I just don’t know any way to fix this. Any help is appreciated. Oh and if you want the code just ask me and I will post it. I don’t do it now because this question is long enough.

  1. I see two possibilities:

    a) more likely: you try to compile your project at a location shared between Win7 and Linux without make clean. The object files the compiler generates are different on each platform, thus you try to link with incompatible object files. Just do a Rebuild all.

    b) less likely: the project might be set up as pure C, and you try to compile it as C++. Then, the correct decision would be to recreate the project correctly.

Originally posted 2013-11-27 12:26:07.