I have three files:
lib.c lib.h => They should be built as a .so file
client.c => This should be built as an executable.
Inside the client.c I include the lib.h file so as to get the declarations of the functions defined under lib.c
Can someone tell me the exact CMakeLists file that I should be using so that the source area is uncluttered with Cmake's temporary files and the binaries and the libraries (.dlls in case of windows I believe) generated in separate build and binary directories ?
Add a subdirectory to the build. Adds a subdirectory to the build. The source_dir specifies the directory in which the source CMakeLists.
Adds a library target called <name> to be built from the source files listed in the command invocation. The <name> corresponds to the logical target name and must be globally unique within a project. The actual file name of the library built is constructed based on conventions of the native platform (such as lib<name>.
This solution will not create a .so
file, but a cmake equivalent for further inclusion with cmake.
I am searching for a solution with will provide the equivalent to this:
g++ -shared -Wl,-soname,plugin_lib.so.1 -o plugin_lib.so plugin_lib.o
Which will generate a plugin_lib.so
that can be loaded dynamically with dlopen at runtime.
The solution is missing the "SHARED" option like so:
ADD_LIBRARY(mylib SHARED ${mylibSRCS})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With