Skip to content Skip to sidebar Skip to footer

Libpython Error While Building Youcompleteme

I am building YouCompleteMe plugin of vim, following this document. When I run make I get the following error. Linking CXX shared library /home/sagar/.vim/bundle/YouCompleteMe/pyt

Solution 1:

Make the linker point to the .so (shared object) file and not the .a (static lib) file.

You can do this specifying the flag when running cmake:

cmake -G "Unix Makefiles" -DPYTHON_LIBRARY=/usr/local/lib/libpython2.7.so . ~/.vim/bundle/YouCompleteme/cpp

Do mind that even though you're using pyenv, YouCompleteMe build may point to an undesired python build as they are not correctly auto-detected right now.

If you're having this problem, you should probably also specify the Python header files correctly:

cmake -G "Unix Makefiles" -DPYTHON_LIBRARY=/usr/local/lib/libpython2.7.so -DPYTHON_INCLUDE_DIR=/usr/local/include/python . ~/.vim/bundle/YouCompleteme/cpp

PS=(I'm assuming your headers are in that path, do check before)

Solution 2:

Since some paths were different on my system from the accepted answer (both the CMake and the python lib ones) I'm posting an alternate solution for the above problem:

  1. Make sure to have a shared library version of libpython2.7.so

    $ locate libpython
    /usr/lib/x86_64-linux-gnu/libpython2.7.so.1
    
  2. Either create a symlink to it from where CMake expects it to be

    sudo ln -s "/usr/lib/x86_64-linux-gnu/libpython2.7.so.1""/usr/lib/libpython2.7.so"

    or alternatively, as written in YCM's build script code, you could add additional CMake options to ensure the .so library is properly found

    export EXTRA_CMAKE_ARGS="-DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython2.7.so.1"

Post a Comment for "Libpython Error While Building Youcompleteme"