I'm writing a recursive flood-fill algorithm to find connected components in an image, my code compiles and runs well with MSVC 2008 compiler; but the mingw-compiled binary crashed at runtime.
After I converted the algorithm to non-recursive with std::stack, everything goes well.
But what if I must use recursive algorithm in some case, and mingw cannot handle it?
How can I increased stack size of a binary, is there any compilation options?
Thanks
Use
gcc -Wl,--stack,N
where N is stack size. E.g. gcc -Wl,--stack,4194304
Maybe increasing stack size is not the solution you want. These restrictions do exist for a reason. It also may happen that in a near future your algorithm will use even more stack space and you will have to increase it again.
Perhaps you should consider converting your algorithm into a non-recursive one. This can be done for every algorithm. See this discussion
And you will probably gain a performance improvement also
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With