Has anyone managed to compile igraph into a shared library, and link dependencies statically?
This has been a problem for me on Windows when using MSYS2. Normally, anything compiled with MSYS2’s MinGW will depend on
libwinpthread-1.dll. One can verify using Dependency Walker whether these dependencies are present.
I’ve been struggling to get rid of these. StackOverflow says that one can use the compiler flags
-static -static-libgcc -static-libstdc++ to avoid these dependencies. I tried this using a minimal C++ example program that was compiled as
g++ -static -static-libgcc -static-libstdc++ -shared -o foo.dll foo.cpp
and it appears to work.
But if I compile igraph as follows, it does not work:
export CFLAGS="-static-libgcc -static-libstdc++" CXXFLAGS="-static-libgcc -static-libstdc++" LDFLAGS="-static-libgcc -static-libstdc++" ./configure --disable-gmp --disable-graphml --with-pic make
--disable-gmp --disable-graphml to keep things as minimal as possible. If I look at the linking step of the output, I see
libtool being called, and the above flags are indeed passed to it. But then if I open
libigraph-0.dll with depwalker, I still see a dependency on
I think that autotools and libtool, which I am not familiar with, somehow prevent static linking here. Unfortunately, I do not have sufficient technical knowlegde to udnerstand what is going on, and I could not solve this even after spending a considerable amount of time googling and searching StackOverflow.
For a high-level interface, having these dependencies is not okay because another package may load an incompatible version of the same DLLs.
@tamas, will cmake help with this eventually?