您好,我在 Code::Blocks 中构建程序时遇到问题。 问题是当我构建代码时,它开始给我各种不相关的错误,例如:
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'
....等等
问题是在我在我的 Ubuntu 11.04 中编辑相同的程序之前它在 Windows 7 上运行没有问题。我只是不知道有什么方法可以解决这个问题。任何帮助表示赞赏。哦,如果你想要代码就问我,我会把它贴出来。我现在不做,因为这个问题已经够长了。
最佳答案
我看到两种可能性:
a) 更有可能:您尝试在没有make clean
的情况下在 Win7 和 Linux 共享的位置编译您的项目。编译器生成的目标文件在每个平台上都不同,因此您尝试链接不兼容的目标文件。只需执行 全部重建
。
b) 不太可能:项目可能被设置为纯 C,而您尝试将其编译为 C++。那么,正确的决定就是正确地重新创建项目。
关于c++ - 代码::积木问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6865011/