CMake: creating static binary code

I am trying to create static binary using CMake.

I looked around and found some non-descriptive solutions (for example, add the linker flag “-static”), but I'm not sure how to test them.

How do I know if there was a static insertion of a specific library (e.g. Threading) into my binary?

+3
source share
3 answers

As the track says, use lddto get a list of dynamically linked libraries that your executable depends on, and make sure that the code you want to statically link is not .

nm strings , . grep , , , .

, objdump, . .

, , , , , , . , .

+3

CMake, UNIX, file , , , .

+1

On Linux, you can also use a command lddthat shows in which libraries your binary references are dynamic.

+1
source

Source: https://habr.com/ru/post/1790803/


All Articles