简体   繁体   中英

Create a .so file with everything statically linked(include libc) in CMake

I want to create a .so shared object that statically linked with musl libc(or some other libc). So that others can dynamically linked with my .so file during runtime without worrying having certain libc on their platform. Is this possible ? If so, how can I achieve this in CMake ?

You should be able to achieve this by statically linking to dependent libraries in your shared library and making such linkage private (ie target_link_libraries(MyLib PRIVATE dependencies...) ).

Then you will have to ensure that no part of any of the dependent libraries is exposed to a consumer of your shared library (including any headers counts as exposure). The PImpl technique will probably be of use to you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM