Create a shared library for dlib

后端 未结 2 2039
孤街浪徒
孤街浪徒 2021-02-14 22:36

Following the instructions to compile dlib using cmake (here) generates a static dlib library:

cd examples
mkdir build
cd build
cmake ..
cmake --build . --config         


        
2条回答
  •  -上瘾入骨i
    2021-02-14 22:55

    According to dlib/CMakeLists.txt, standalone (not from examples) building of dlib also creates shared library named dlib-shared:

    mkdir shared_build # Build directory can be any
    cd shared_build
    cmake ..
    cmake --build . --config Release
    make install # Install library for make it acessible for others
    

    For use this library in examples, you need to add definition of dlib library into your examples/CMakeLists.txt before include(../dlib/cmake).

    examples/CMakeLists.txt:

    ...
    PROJECT(examples)
    
    add_library(dlib SHARED IMPORTED) # Imported(!) dlib target
    set_target_properties(dlib PROPERTIES IMPORTED_LOCATION "")
    
    # Now it is safe to include other dlib infrustucture - it won't build dlib again.
    include(../dlib/cmake)
    ...
    

提交回复
热议问题