YouCompleteMe安装问题

时间:2015-06-16 18:18:48

标签: vim vim-plugin

我正在尝试在运行Debian Linux(在我的用户主页)的大学服务器上安装YouCompleteMe。 我跑的时候:

./install.sh

在"构建CXX对象后,我收到以下错误"阶段。

[ 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:

错误消息显示&#34;重新使用-fPIC&#34;我必须重新编译什么?谢谢。

1 个答案:

答案 0 :(得分:1)

我刚刚解决了这个问题;和你的一样:我安装了自己的Python。我引用了this solution,但我以一种不同的方式做到了。

  1. 首先检查你自己的lib目录中是否有libpython2.7.so(在你的情况下是〜/ lib /)。如果只有libpython2.7.a,则可能需要为共享库重新编译python。查看this以获取参考。简而言之,你应该去你的python源代码,并且:

    ./configure --enable-shared \
                --prefix=$HOME \
                LDFLAGS="-Wl,--rpath=$HOME/lib
    make
    make install
    
  2. 如果你的系统有自己的Python,你可能会遇到麻烦。问题如下:

  3.   

    / usr / bin / ld:/usr/local/lib/libpython2.7.a(abstract.o):在创建共享对象时,不能使用针对`.rodata.str1.8'的重定位R_X86_64_32;使用-fPIC /usr/local/lib/libpython2.7.a重新编译:无法读取符号:错误值

    在这种情况下,请参阅this solution并返回步骤1.

    否则,请继续。

    1. 现在我假设您的lib目录中有libpython2.7.so。稍微改变~/.vim/bundle/YouCompleteMe/third_party/ycmd/build.py

      • 修改函数CustomPythonCmakeArgs(),替换

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

        python_library = '{0}.so'.format( lib_python )
        
      • 在附近添加一行

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

      您的python解释器可能位于其他位置,请相应更改。

      • 更改

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

        return [
            '-DPYTHON_LIBRARY={0}'.format( python_library ),
            '-DPYTHON_INCLUDE_DIR={0}'.format( python_include ),
            '-DPYTHON_EXECUTABLE={0}'.format( python_executable ), 
        ]
        
      • 还记得发表评论

        if OnMac():
            full_cmake_args.extend( CustomPythonCmakeArgs() )
        
        像这样

        # if OnMac():
        full_cmake_args.extend( CustomPythonCmakeArgs() )
        
    2. 做完这些之后,你应该做得很好。返回~/.vim/bundle/YouCompleteMe并重新安装

      ./install.py --clang-completer