Reputation: 3523
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__
Upvotes: 0
Views: 6853
Reputation: 62603
As suggested by OP, posting my comment as an answer: for this you need to pass -m64 option to compiler/linker.
Upvotes: 3
Reputation: 1042
You have to tell CLion to use MinGW-w64 to build your CMake project.
You dont have to change your CMake project configuration. It would be counterproductive limiting your CMake project by a fixed machine architecture, if you can instead easily tell your compiler which architecture to build for or use an appropriate compiler (MinGW-w64
).
This post shows you how to do that:
https://dev.my-gate.net/2014/09/15/how-to-use-mingw-w64-with-clion/
Excerpt from this post:
Here are the few steps to make it work:
After building your executable, you can check its architecture with the unix command file
, which should be available to you since you are using mingw.
Upvotes: 4