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.
                        
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.
First check if you have
libpython2.7.soin your own lib dir (in your case it's ~/lib/). If there's onlylibpython2.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:You could run into trouble if your system has a Python itself. The issue looks like:
In this case, please refer to this solution and go back to step 1.
Otherwise, just go ahead.
Now I assume you have
libpython2.7.soin your lib dir. Change~/.vim/bundle/YouCompleteMe/third_party/ycmd/build.pya little bit:Modify the function
CustomPythonCmakeArgs(), replacingwith
Add a line nearby
Your python interpreter may be in some other location, change it accordingly.
Change the return value from
to
Also remember to comment out
like this
You should be good after doing these. Go back to
~/.vim/bundle/YouCompleteMeand install again