In OSX during C++ program compilation with g++ I use
g++
LD_FLAGS= -Wl,-stack_size,0x100000000
Change it with the ulimit bash builtin, or setrlimit(), or at login with PAM (pam_limits.so).
It's a settable user resource limit; see RLIMIT_STACK in setrlimit(2).
http://bytes.com/topic/c/answers/221976-enlarge-stack-size-gcc