本人的操作系统环境centos 6.6在安装vim的YCM插件时出现错误。
vim为自己编译,已添加相应的解释语言支持。
系统自带的python版本为2.6,本人编译添加了2.7以及3.4版本,所以本人的环境中有这三个版本。
进入YCM目录,执行命令安装时,出现的错误如下:
[ 90%] Building CXX object ycm/CMakeFiles/ycm_client_support.dir/Result.cpp.o
Linking CXX shared library /home/xuanyuan/k-vim/bundle/YouCompleteMe/third_party/ycmd/ycm_client_support.so
/usr/bin/ld: /usr/local/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
/usr/local/lib/libpython2.7.a: could not read symbols: Bad value
collect2: 错误:ld 返回 1
gmake[3]: * [/home/xuanyuan/k-vim/bundle/YouCompleteMe/third_party/ycmd/ycm_client_support.so] 错误 1
gmake[2]: * [ycm/CMakeFiles/ycm_client_support.dir/all] 错误 2
gmake[1]: * [ycm/CMakeFiles/ycm_support_libs.dir/rule] 错误 2
gmake: * [ycm_support_libs] 错误 2
Traceback (most recent call last):
File "/home/xuanyuan/k-vim/bundle/YouCompleteMe/third_party/ycmd/build.py", line 327, in <module>
Main()
File "/home/xuanyuan/k-vim/bundle/YouCompleteMe/third_party/ycmd/build.py", line 316, in Main
BuildYcmdLibs( args )
File "/home/xuanyuan/k-vim/bundle/YouCompleteMe/third_party/ycmd/build.py", line 261, in BuildYcmdLibs
subprocess.check_call( build_command )
File "/usr/local/lib/python2.7/subprocess.py", line 540, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--target', 'ycm_support_libs', '--', '-j', '1']' returned non-zero exit status 2
Traceback (most recent call last):
File "./install.py", line 32, in <module>
Main()
File "./install.py", line 21, in Main
subprocess.check_call( [ python_binary, build_file ] + sys.argv[1:] )
File "/usr/local/lib/python2.7/subprocess.py", line 540, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/usr/local/bin/python', '/home/xuanyuan/k-vim/bundle/YouCompleteMe/third_party/ycmd/build.py']' returned non-zero exit status 1
求解决办法?
已解决:
第一步:缺少python2.7的共享库,重新编译安装python2.7加入编译选项--enable-shared。
如果问题解决,不需要执行以下步骤,如果出现以下错误:
可能由于多个版本的python导致,以下错误:
python: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory
出现这种错误的解决办法:
第二步:
编辑/etc/ld.so.conf文件,新加入以下内容/usr/local/lib,直接添加新的一行即可。
保存后,执行以下命令( ---> 为命令提示符,每个人可以根据需要自己设置):
---> /sbin/ldconfig
---> /sbin/ldconfig –v