JackHuVandy
JackHuVandy

Reputation: 55

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!

Upvotes: 4

Views: 18198

Answers (4)

Nassima Noufail
Nassima Noufail

Reputation: 237

That might be a late answer, but for anyone who's asking for that, changing the option "linker for dynamic libs" from gcc to g++ works for me

Upvotes: 0

Jichao
Jichao

Reputation: 41805

  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 detail configuration image
  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

Upvotes: 5

milleniumbug
milleniumbug

Reputation: 15814

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]"

Upvotes: 5

mrmoje
mrmoje

Reputation: 3732

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

Upvotes: 2

Related Questions