Change stack size for a C++ application in Linux during compilation with GNU compiler

前端 未结 4 1893
轻奢々
轻奢々 2020-11-22 03:42

In OSX during C++ program compilation with g++ I use

LD_FLAGS= -Wl,-stack_size,0x100000000

4条回答
  •  我在风中等你
    2020-11-22 04:32

    Instead of stack_size, use --stack like so:

    gcc -Wl,--stack,4194304 -o program program.c
    

    This example should give you 4 MB of stack space. Works on MinGW's GCC, but as the manpage says, "This option is specific to the i386 PE targeted port of the linker" (i.e. only works for outputting Windows binaries). Seems like there isn't an option for ELF binaries.

提交回复
热议问题