views:

35

answers:

2

Hi,

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

A: 

probably the best bet is to use pthreads to start a new thread and run your algorithm in the new thread. One of the parameters to pthread_create is pthread_attr_t. Using this attribute you can specify the stack size (by calling pthread_attr_setstacksize).

Edit: Whether this works or not is dependent on support of the underlying compatibility layer

doron
+1  A: 

Use

gcc -Wl,--stack,N

where N is stack size. E.g. gcc -Wl,--stack,4194304