0

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.

Bart
  • 19,692
  • 7
  • 68
  • 77
Ikaros
  • 11
  • 3
  • 2
    maybe you forgot to specify the necessary libraries in your include path? – sled Jul 28 '11 at 20:08
  • As @sled says, those are link errors. – Paul R Jul 28 '11 at 20:11
  • What are the libs you're currently linking against? – Bart Jul 28 '11 at 20:35
  • i dont know doesn't it seems from the errors? – Ikaros Jul 28 '11 at 20:40
  • 1
    @Ikaros: Welcome to stackoverflow. If the answer below solves your problem, then you should accept this answer by clicking on the checkmark next to the upvote/downvote number. This will mark the question as answered. I think it will also give you a couple of reputation points. – Emile Cormier Jul 28 '11 at 21:03

1 Answers1

3

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.

vines
  • 5,160
  • 1
  • 27
  • 49
  • When you've made the wrong choice (C instead of C++) in the Code::Blocks startup wizard, you can still fixed it. You don't need to recreate the project (option b). In the C::B "File" menu choose "Properties", tab "Advanced", change "Compiler variable" from "CC" to "GCC". – hennep Jul 09 '23 at 13:00
  • The other answer marked as a [duplicate] is not a question about Code::Blocks so not a duplicate. It is an IDE independent question, probably executed from the command line. How do we remove the [duplicate]-marking? – hennep Jul 09 '23 at 13:07