c++cmake

On linux, how to generate libOpenXLSX.so instead of libOpenXLSX.a


I am trying to generate a shared object file from OpenXLSX Git repository.

Per this page, https://github.com/troldal/OpenXLSX:

OpenXLSX can generate either a shared library or a static library. By default it will produce a shared library, but you can change that in the OpenXLSX CMakeLists.txt file.

I have used the default settings and commands but I am getting a libOpenXLSX.a file in /usr/local/lib64 instead of libOpenXLSX.so.

mkdir build
cd build
cmake ..
cmake --build . --target OpenXLSX --config Release
cmake --install .

Trying to understand what is the flag/settings that can generate the .so file

Please let me know what I could be missing?


Solution

  • You can try to configure with either of the following commands:

    OPENXLSX_LIBRARY_TYPE=SHARED cmake ..
    # or
    cmake .. -DOPENXLSX_LIBRARY_TYPE=SHARED
    

    Another alternative follows.

    Edit line 35 of file CMakeLists.txt to read

    set(OPENXLSX_LIBRARY_TYPE "SHARED")