I am building a C++ project on Linux using gcc 9.2 and cmake 3.15, and I need to increase the default stack size. I found many answers before, but none of them seems to work
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--stack,1000000")
message(${CMAKE_CXX_COMPILER_ID})
message(${CMAKE_EXE_LINKER_FLAGS})
It gives an error:
/usr/bin/ld: unrecognized option '--stack'
/usr/bin/ld: use the --help option for usage information
I can see the argument is indeed is passed in the cmake output:
GNU
-Wl,--stack,1000000
And this following flag doesn't seems to exist at all.
set(CMAKE_CXX_STACK_SIZE 1000000)
Solved. Thanks for @squareskittles 's comment. It should be:
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,stack-size=1000000")
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