【问题标题】:YouCompleteMe Installation ProblemsYouCompleteMe 安装问题
【发布时间】:2015-06-16 18:18:48
【问题描述】:

我正在尝试在运行 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:

错误消息显示“使用 -fPIC 重新编译”我必须重新编译什么?谢谢。

【问题讨论】:

  • 你自己编译过python版本吗? (为什么在~/lib/libpython2.7.a找python?)
  • 是的,我有自己的 python.. 我检查了 ~/lib/libpython2.7.a 并且文件存在.. 我必须重新安装 python 吗?
  • 也许吧?我真的不知道。我的猜测是 python 的配置很奇怪。它也应该与编译 vim 的版本相同。

标签: vim vim-plugin


【解决方案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,您可能会遇到麻烦。问题如下:

/usr/bin/ld: /usr/local/lib/libpython2.7.a(abstract.o): relocation R_X86_64_32 against `.rodata.str1.8' 不能在制作共享对象时使用;使用 -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() )
      

做完这些你应该就好了。回到~/.vim/bundle/YouCompleteMe重新安装

./install.py --clang-completer

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-05
    • 1970-01-01
    • 2021-05-31
    • 2016-12-13
    • 1970-01-01
    • 2012-05-07
    相关资源
    最近更新 更多