YouCompleteMe Installation Problems

4.5k views Asked by At

I am trying to install YouCompleteMe on my university server which runs Debian Linux(in my user home). When I run:

./install.sh

I get the following error after the "Building CXX object" stage.

[ 98%] Building CXX object ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o
[100%] Building CXX object     ycm/CMakeFiles/ycm_client_support.dir/versioning.cpp.o
[100%] Building CXX object ycm/CMakeFiles/ycm_client_support.dir/ycm_client_support.cpp.o
Linking CXX shared library   /home/arenduc1/.vim/bundle/YouCompleteMe/third_party/ycmd/ycm_client_support.so
/usr/bin/ld: /home/arenduc1/lib/../lib/libpython2.7.a(abstract.o): relocation   R_X86_64_32S against `_Py_NotImplementedStruct' can not be used when making a   shared object; recompile with -fPIC
/home/arenduc1/lib/../lib/libpython2.7.a: could not read symbols: Bad value
collect2: error: ld returned 1 exit status
make[3]: ***    [/home/arenduc1/.vim/bundle/YouCompleteMe/third_party/ycmd/ycm_client_support.so]    Error 1
make[2]: *** [ycm/CMakeFiles/ycm_client_support.dir/all] Error 2
make[2]: *** Waiting for unfinished jobs....
Linking CXX shared library   /home/arenduc1/.vim/bundle/YouCompleteMe/third_party/ycmd/ycm_core.so
/usr/bin/ld: /home/arenduc1/lib/../lib/libpython2.7.a(abstract.o): relocation   R_X86_64_32S against `_Py_NotImplementedStruct' can not be used when making a   shared object; recompile with -fPIC
/home/arenduc1/lib/../lib/libpython2.7.a: could not read symbols: Bad value
collect2: error: ld returned 1 exit status
make[3]: ***   [/home/arenduc1/.vim/bundle/YouCompleteMe/third_party/ycmd/ycm_core.so] Error 1
make[2]: *** [ycm/CMakeFiles/ycm_core.dir/all] Error 2
make[1]: *** [ycm/CMakeFiles/ycm_support_libs.dir/rule] Error 2
make: *** [ycm_support_libs] Error 2
Traceback (most recent call last):
  File "/home/arenduc1/.vim/bundle/YouCompleteMe/third_party/ycmd/build.py", line 196, in <module>
    Main()
  File "/home/arenduc1/.vim/bundle/YouCompleteMe/third_party/ycmd/build.py", line 189, in Main
    BuildYcmdLibs( GetCmakeArgs( args ) )
  File "/home/arenduc1/.vim/bundle/YouCompleteMe/third_party/ycmd/build.py", line 152, in BuildYcmdLibs
_err = sys.stderr )
  File "/home/arenduc1/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/sh/sh.py",   line 1021, in __call__
    return RunningCommand(cmd, call_args, stdin, stdout, stderr)
  File    "/home/arenduc1/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/sh/sh.py",   line 486, in __init__
    self.wait()
  File   "/home/arenduc1/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/sh/sh.py",  line 500, in wait
    self.handle_command_exit_code(exit_code)
  File  "/home/arenduc1/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/sh/sh.py",  line 516, in handle_command_exit_code
    raise exc(self.ran, self.process.stdout, self.process.stderr)
sh.ErrorReturnCode_2:

  RAN: '/usr/bin/make -j 2 ycm_support_libs'

  STDOUT:
  STDERR:

The error message says "recomile using -fPIC" what must I recompile? Thank you.

1

There are 1 answers

0
misaka-10032 On

I just resolved this issue; same as yours: I have my own Python installed. I referenced this solution, yet I did it in a little bit different way.

  1. First check if you have libpython2.7.so in your own lib dir (in your case it's ~/lib/). If there's only libpython2.7.a, you may need to recompile python for the shared library. Look to this for reference. In short you should go to your python source code, and:

    ./configure --enable-shared \
                --prefix=$HOME \
                LDFLAGS="-Wl,--rpath=$HOME/lib
    make
    make install
    
  2. You could run into trouble if your system has a Python itself. The issue looks like:

/usr/bin/ld: /usr/local/lib/libpython2.7.a(abstract.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC /usr/local/lib/libpython2.7.a: could not read symbols: Bad value

In this case, please refer to this solution and go back to step 1.

Otherwise, just go ahead.

  1. Now I assume you have libpython2.7.so in your lib dir. Change ~/.vim/bundle/YouCompleteMe/third_party/ycmd/build.py a little bit:

    • Modify the function CustomPythonCmakeArgs(), replacing

      python_library = '{0}.a'.format( lib_python )
      

      with

      python_library = '{0}.so'.format( lib_python )
      
    • Add a line nearby

      python_executable = '{0}/bin/python'.format( python_prefix )
      

    Your python interpreter may be in some other location, change it accordingly.

    • Change the return value from

      return [
          '-DPYTHON_LIBRARY={0}'.format( python_library ),
          '-DPYTHON_INCLUDE_DIR={0}'.format( python_include ),
      ]
      

      to

      return [
          '-DPYTHON_LIBRARY={0}'.format( python_library ),
          '-DPYTHON_INCLUDE_DIR={0}'.format( python_include ),
          '-DPYTHON_EXECUTABLE={0}'.format( python_executable ), 
      ]
      
    • Also remember to comment out

      if OnMac():
          full_cmake_args.extend( CustomPythonCmakeArgs() )
      

      like this

      # if OnMac():
      full_cmake_args.extend( CustomPythonCmakeArgs() )
      

You should be good after doing these. Go back to ~/.vim/bundle/YouCompleteMe and install again

./install.py --clang-completer