3

I have a CMakeLists.txt for creating a static lib, and I want to pack it with all the dependencies it will need so that the users of my lib don't need to download the libs it depends on.

e.g., my lib depends on OpenCV, so I don't want my users to download OpenCV in order to use my lib.

How can I accomplish this?

For now, I have the following,

file(GLOB LIB_SOURCES
    *.cpp
)


include_directories(include)
include_directories(tools)

add_library(myLib STATIC ${LIB_SOURCES})
target_link_libraries(myLib ${OpenCV_LIBS})
manatttta
  • 3,054
  • 4
  • 34
  • 72
  • 1
    This can be a huge effort and problem. You'll have to ship all libraries for **all** possible platforms (eg, linux, win, mac) and for every possible compiler (gcc, clang, vc++) and architecture (x86, x86_64). – ollo Mar 19 '16 at 21:00
  • @ollo the idea was to only provide my dynamic library, with all symbols defined within it – manatttta Mar 21 '16 at 20:34
  • You can always use your libraries / dependencies target / `*_LIBS` variable to access the path. Maybe this can help you too: http://stackoverflow.com/questions/31503597/cmake-link-a-shared-library-to-static-libraries – ollo Mar 24 '16 at 19:31
  • Why in particular do you want the result to be a static library and not a dynamic one? While I don't know the topic that deeply, I can't logically understand why one would want that. If you want to merge DLLs into one DLL, see [Combine multiple DLL's into 1](/q/3595937/11107541), and for .so files, see [Merge multiple .so shared libraries](/q/915128/11107541). – starball Jan 19 '23 at 00:48

0 Answers0