Increase stack size when compiling with mingw?
Use
gcc -Wl,--stack,N
where N is stack size. E.g. gcc -Wl,--stack,4194304
How to increase stack size when compiling a C++ program using MinGW compiler
In order to change the size of the stack to run a C++ program that may cause a stack overflow, use the following command.
g++ -Wl,--stack,16777216 -o file.exe file.cpp
This increases the stack size to 16MiB, if you need it to be bigger then increase the value from 16777216
bytes to whatever value you need.
Do be sure to replace file.exe
and file.cpp
with the corresponding names of the file and executable that you are running.
Also note that in the command its -Wl
(lower case L)
How to deal with the small stack size in MinGW?
You really should avoid using the stack for large things.
It's also a security risk as stack overflows wan be abused by hackers (e.g. to try to attempt running arbitrary code).
Better is to use the heap, you can do this by replacing
double Ar2D[arraySize][arraySize];
with
double** Ar2D = (double**)malloc(arraySize * arraySize * sizeof(double));
and of course don't forget to free(Ar2D);
Increase stack size in c++
I have solved problem, It should work in all IDEs I think, but it definitely works in Visual Studio. PROJECT->Properties->Configuration Properties->Linker->System->Stack Reserve Size=4194304 . This makes stack size 4 MB.
Related Topics
Is It a Good Practice to Always Use Smart Pointers
Troubles with Boost::Spirit::Lex & Whitespace
Read Func Interp of a Z3 Array from the Z3 Model
C++ Get Handle of Open Sockets of a Program
Differencebetween If (Null == Pointer) VS If (Pointer == Null)
Trying to Use a While Statement to Validate User Input C++
Increase Stack Size When Compiling with Mingw
Memory Allocation/Deallocation
How to Get the Current Windows System-Wide Timer Resolution
Which Is Faster:If (Bool) or If(Int)
Compiling Code Containing Dynamic Parallelism Fails
Branch Prediction on a Function Pointer
Std::Filesystem' Has Not Been Declared After Including <Experimental/Filesystem>
How Does the Stl's Multimap Insert Respect Orderings
C++: Why Does Space Always Terminate a String When Read
Undefined Behavior in C/C++: I++ + ++I VS ++I + I++