Search code examples
vimldd

Vim dynamic linked dependency not listed via ldd


Install vim from source successfully

$ git clone https://github.com/vim/vim && cd vim
$ ./configure --prefix=/usr/local --enable-gui=no --enable-python3interp=dynamic
$ make CFLAGS='-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1'
$ sudo make install

Test the plugin in python3 successfully

python3 << EOF
print("Hello, Python3!")
EOF

Check if python3 dynamically linked

$ /usr/local/bin/vim --version
+python3/dyna
$ ll -h /usr/local/bin/vim
2.6M
$ ldconfig -p | grep python3
libpython3
$ ldd /usr/local/bin/vim | grep python
(nothing)

Something libpython3 should have been listed, why does nothing show up here?


Solution

  • When you use dynamic the library is not linked, it is loaded by the vim binary on the first use, using dlopen(). From :help python-dynamic:

    On MS-Windows and Unix the Python library can be loaded dynamically. The :version output then includes +python/dyn or +python3/dyn.

    This means that Vim will search for the Python DLL or shared library file only when needed. When you don't use the Python interface you don't need it, thus you can use Vim without this file.

    ...

    The 'pythondll' or 'pythonthreedll' option can be used to specify the Python shared library file ...

    and :help 'pythonthreedll':

    Specifies the name of the Python 3 shared library. The default is DYNAMIC_PYTHON3_DLL, which was specified at compile time.