简体   繁体   中英

How can I update code::blocks to use TDM-GCC?

I need to use unique_ptr in my C++ assignment.

I downloaded a new compiler, TDM-GCC-4.7.1, and installed it. Then I changed the directory of GNU GCC Compiler to the installation path in option: Setting->Compiler...->Toolchain Executable .

But it doesn't work. When I define a unique_ptr . A error would occur: "unique pointer is not a command of 'std' "

The reason of using smart pointer is to provide strong exception safety, which is also a requirement of this assignment. I just need to use this new feature of C++11... Plus, the OS I use is Window 7.

Thanks!

In CodeBlocks you can set C++11 mode either in project compiler settings or global compiler settings. Since you may be using it more often, here is how you change it globally:

Go to Settings -> Compiler -> (There should be list of options here, in Compiler flags) -> Select "Have g++ follow the C++11 ISO C++ language standard [-std=c++11]"

Here is how to change it for a single project:

Go to Project -> Build options -> (There should be list of options here, in Compiler flags) -> Select "Have g++ follow the C++11 ISO C++ language standard [-std=c++11]"

  1. Download the latest tdm-gcc http://tdm-gcc.tdragon.net
  2. Settings->Compiler, Selected Compiler [GNU GCC Compiler] Copy and Create a new configuration [GNU GCC Compiler 4.9.2]
  3. Detail configuration 详细配置图像
  4. Set the new compiler configuration as default by click Set as default
  5. Change Compiler settings to having c++11 .

PS: code::blocks ver 13.12, tdm-gcc 4.9.2

  1. Remember to #include <memory>
  2. Add -std=gnu++0x or -std=c++11 compiler flags......whichever works

这可能是一个迟到的答案,但对于任何要求它的人,将选项“动态库的链接器”从gcc更改为g ++对我有用

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM