I need to provide an SDK with a static library. Let's call it "libsdk.a". This library should hopefully be standalone, meaning a simple example "example.cpp" could link against it without any other library, except the system ones.
Here my configuration:
At the moment, I tried this:
So my final question: is there any way I can generate my static lib containing all my other libs, and not system ones?
BTW, another interesting topic on that: Combining static libraries
Thank you for any piece of advice to open my mind !
What you are trying to do by hand is the job of the linker. While it's feasible, you shouldn't bother with it.
When you compile libsdk.a
, make sure that all of its dependencies are linked statically. If you do this, libsdk.a
should be standalone. Static linking means copying the code to the right places in the final executable, so anything that is linked statically will not need to be provided in an external file.
See this post on CMake mailing list . libutils.cmake attached to the message has MERGE_STATIC_LIBS() macro that does the job. On Linux (and all other Unixes except OSX) it uses ar to pack and unpack objects files.
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.