I am using our sample project to try to generate .SO file, the following are my Cmake file code, I don’t know how to generate the .SO file by using our CMake file.
If you want to create a library instead of an executable, use add_library instead of add_executable.
That said, this question is not related to igraph in any way. For general programming related questions, I suggest StackOverflow. CMake also have their forum.
Thank you for your reply. Next time I will post the general programming related questions to Other forums. But for this one, it’s a little bit difference. Because when I try to create the .SO file, I will got an error, I only can create .a file.
The reason is when I installed our igraph library, it gerneated an libigraph.a file, which is an STATIC library object, if I want to generate a .SO file, I have to use DYNAMIC library to genreate that. But I don’t know how to do that. It seems like I need to generate an libigraph.so file first, then I can use our Cmake file to generate a .SO file.
This is also a more general CMake related question. You probably want to read their documentation. If you don’t find an answer there, you can probably better ask for directions on their forum.
In this case, you should probably check out whether BUILD_SHARED_LIBS does what you want.
This flag is on by default for shared libraries. It is only explicitly needed in more complicated cases I believe (e.g. static libraries linked into dynamic libraries).
Thank you for your suggestion. Now I can gerneate the .SO file for no problem. The process is I need to go to the igraph-0.10.4/CmakeLists.txt to do the following change:
# Expose the BUILD_SHARED_LIBS option in the ccmake UI
#option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
I need to switch the OFF tag to ON. And then I need to add the following Code to the target project’s Cmake.txt file:
add_library(XXX SHARED XXX.cpp)
After this, I can generate .SO file for no problem. The reason is if I want to generate .SO file, I need to generate the shared lib for iGraph first, and then using the igraph.so to generate my project .SO file.