How to set the stack size with the gcc compiler

Asked by femyers01

I'm running out of stack in a fairly large program that I've written in c++ using the QT GUI support. Compiles using gcc under Ubuntu 8.04. The program is multi threaded and has worked for well over a year until I added a few more features. There must be some way to set the stack size either with a #pragma or a linker option but I haven't been able to find anything in the documentation. It seems like such a simple thing but I have not been able to find it.

Forrest Myers
AG4ND

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu gcc-defaults Edit question
Assignee:
No assignee Edit question
Solved by:
Gabe Gorelick
Solved:
Last query:
Last reply:
Revision history for this message
Best Gabe Gorelick (gabegorelick) said :
#1

You can't change the stack size through gcc, since it is actually a user resource limit and not related to individual executables. However, you can change the stack size programmatically using setrlimit(RLIMIT_STACK, rlim). Check the setrlimit man page for more details. Or you can use the ulimit bash builtin command to set it in bash.

Revision history for this message
femyers01 (fmyers) said :
#2

Thanks a lot for the help. This looks like what I need.

Forrest Myers
AG4ND