Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make gcc link libssp statically?

Tags:

linux

gcc

How can I get GCC to use that static library instead of the dynamic one? Normally you add the .a file to the linker parameters. But libssp linking is triggered by the -fstack-protector option. And compiler prefers linking to the shared library if it finds one instead of static library.

If I try to run the resulting program on systems that don't have the libssp.so the program won't run.

(After system upgrade on some build machines, the older boxes on the test system screwed up)

like image 985
Calmarius Avatar asked Sep 07 '25 12:09

Calmarius


1 Answers

Does

gcc -static static.c -o static -fstack-protector-all

or

gcc -static -lssp static.c -o static -fstack-protector-all

work? Can you run ldd on the resulting binaries?

What version of gcc are you using?

like image 188
Matt Avatar answered Sep 10 '25 08:09

Matt