0

我正在尝试在 Ubuntu 15.10 上安装带有补丁1-712的 Vim 7.4 的 YouCompleteMe。

我手动编译了 YouCompleteMe,因为我遇到了如下错误:

/usr/bin/ld: /usr/local/lib/libpython2.7.a(abstract.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC

常见问题部分所述,添加-DPYTHON_LIBRARY=/usr/lib/libpython2.7.so将解决它。因此,改为编译它:

cmake -G "Unix Makefiles" -DPYTHON_LIBRARY=/usr/lib/libpython2.7.so . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp

然后:

cmake --build . --target ycm_support_libs --config Release

这次编译时我没有遇到任何错误,但是当我打开 Vim I 时,我看到的是:

   import ycm_client_support
                            ImportError: /home/austin/.vim/bundle/YouCompleteMe/third_party/ycmd/ycm_client_support.so: undefined symbol: PyUnicodeUCS2_AsWideChar















Error detected while processing function youcompleteme#Enable..<SNR>64_SetUpPython:
line   33:
Traceback (most recent call last):
Press ENTER or type command to continue
Error detected while processing function youcompleteme#Enable..<SNR>64_SetUpPython:
line   33:
  File "<string>", line 29, in <module>
Press ENTER or type command to continue
Error detected while processing function youcompleteme#Enable..<SNR>64_SetUpPython:
line   33:
  File "/home/austin/.vim/bundle/YouCompleteMe/autoload/../python/ycm/youcompleteme.py", line 32, in <module>
Press ENTER or type command to continue
Error detected while processing function youcompleteme#Enable..<SNR>64_SetUpPython:
line   33:
    from ycm.omni_completer import OmniCompleter
Press ENTER or type command to continue
Error detected while processing function youcompleteme#Enable..<SNR>64_SetUpPython:
line   33:
  File "/home/austin/.vim/bundle/YouCompleteMe/autoload/../python/ycm/omni_completer.py", line 22, in <module>
Press ENTER or type command to continue
Error detected while processing function youcompleteme#Enable..<SNR>64_SetUpPython:
line   33:
    from ycmd.completers.completer import Completer
Press ENTER or type command to continue
Error detected while processing function youcompleteme#Enable..<SNR>64_SetUpPyth
on:
line   33:
  File "/home/austin/.vim/bundle/YouCompleteMe/autoload/../third_party/ycmd/ycmd
/completers/completer.py", line 25, in <module>
Press ENTER or type command to continue
Error detected while processing function youcompleteme#Enable..<SNR>64_SetUpPyth
on:
line   33:
    from ycm_client_support import FilterAndSortCandidates
Error detected while processing function youcompleteme#Enable..<SNR>64_SetUpPyth
on:
line   33:
ImportError: /home/austin/.vim/bundle/YouCompleteMe/third_party/ycmd/ycm_client_
support.so: undefined symbol: PyUnicodeUCS2_AsWideChar

有谁知道如何解决这一问题?

4

1 回答 1

0

这看起来像 Python 常见问题解答中描述的问题 => https://docs.python.org/2/faq/extending.html#when-importing-module-x-why-do-i-get-undefined-symbol- pyunicodeucs2

“解决这个问题的唯一方法是使用使用相同大小的 Unicode 字符构建的 Python 二进制文件编译的扩展模块。”

您可以使用以下方法测试 python 的 unicode 字符的大小:

import sys
if sys.maxunicode > 65535:
  print 'UCS4 build'
else:
  print 'UCS2 build'
于 2015-11-03T11:32:59.103 回答