shared library?
adl opened this issue · 5 comments
To build Python bindings for adl/tcltl I need to build a shared library that either embed TChecker (for this the code of TChecker needs to be compiled with -fPIC even of it is a static archive) or that link with a shared version of TChecker.
I think the first option can be achieved by passing some magic variable to cmake
, but that is not necessary convenient for the users. What do you think about changing TChecker to build and install two flavors of the library: a static version and a shared version?
I have updated the CMakeLists.ttxt files to build TChecker shared library. By default, the shared library is not built. Set LIBTCHECKER_ENABLE_SHARED to ON to build the shared library.
Thank you, that works for me.
Two notes:
- The installed library was silently renamed from
liblibtchecker.a
tolibtchecker.a
(I think this makes more sense), and I did not notice the change right away because I still had the old file installed. - On Linux, if you use
sudo make install
to install in a standard location like/usr/local/
you additionally need to runsudo ldconfig
to update theld.so
cache. Otherwriselibtchecker.so
will not be found at run time.
I apologize for the silent renaming. I forgot to mention it in my comments.
Regarding the second point, I have found the following discussion:
http://cmake.3232098.n2.nabble.com/cmake-install-target-doesn-t-run-ldconfig-after-installing-library-td7593744.html
that proposes to add a last install command:
install(CODE “execute_process(COMMAND ldconfig)”)
in the CMakeLists.txt
file. I could run this install command on Linux systems only. Would that be convenient for you?
I believe running such a command would be wrong for people who install TChecker in their home directory, without root privilege. In that case (1) they don't need to run ldconfig
, instead they need to set LD_LIBRARY_PATH
, and (2) they don't have the permission to run ldconfig
anyway so this would fail. If you want to do that automatically, you'd have to check whether you are actually installing something in a directory that is covered by ldconfig
, and that sounds tricky.
In libtool
-based projects, the make install
command also does not update ld.so.cache
, so I'd suggest to keep it this way, but to document it.
Ok thanks