Search code examples
c++c++11cmakemingw-w64clion

Compile C++ as 64Bit with CLion


I have a c++ application that runs a memory-consuming algorithm.

It crushes with error : terminate called after throwing an instance of 'std::bad_alloc' after the allocated memory reaches about 2GB.

I want to compile it as 64Bit so it could allocate more memory from my 64Bit/8GB Ram machine.

How it can be done?

Im working with CLion, building with CMake and using mingw version: mingw-w64\i686-4.8.3-posix-dwarf-rt_v3-rev2 btw - the wingw is installed under C:\Program Files (x86)\mingw-w64 is this related to the issue?

I've been looking here: Detecting 64bit compile in C and (not suprisingly) I can see that my application does not have the __x86_64__


Solution

  • As suggested by OP, posting my comment as an answer: for this you need to pass -m64 option to compiler/linker.