Ubuntu--C++补全代码

来源:互联网 发布:小说编辑软件 编辑:程序博客网 时间:2024/05/20 23:59

概要:每次安装完虚拟机时,都要配置自己的环境,好多问题需要一个一个的寻找答案,浪费自己的时间,所以总结了一下留给以后参考使用

一、安装完成如需使用root身份登录,可打开终端输入以下命令:

 #设置root密码

sudo passwd root

#切换到root用户

sudo -s

想要在登录界面使用root身份登录,可编辑/etc/lightdm/目录下的lightdm.conf文件,如没有此文件,直接创建

/usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf

1.编辑 /usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf
 vim     /usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf

  内容如下

   [SeatDefaults] 

   autologin-user=root 

   user-session=ubuntu 

    greeter-show-manual-login=true

    allow-guest=false

2.编辑 /root/.profile
   vim     /root/.profile

    打开文件后找到“mesg on

    将其更改为“tty  -s  &&  mesg  n

3.用reboot命令重启即可

二、安装Openssh

1、Ubuntu 下安装OPenSSHServer 

sudo apt-get install openssh-server

2、对openssh server 进行配置

vim     /etc/ssh/sshd_config

 找到permitRootLogin on一行,改为PermitRootLogin Yes

3、重启openssh server

 service   sshd   restart

三、ssh client 报 algorithm negotiation failed的解决方法之一

1、修改sshd的配置文件 /etc/ssh/sshd_config

Ciphers aes128-cbc,aes192-cbc,aes256-cbc,aes128-ctr,aes192-ctr,aes256-ctr,3des-cbc,arcfour128,arcfour256,arcfour,blowfish-cbc,cast128-cbc

MACshmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-sha1-96,hmac-md5-96

KexAlgorithms diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group1-sha1,curve25519-sha256@libssh.org

 

2、重启服务

sudo /etc/init.d/ssh restart      重启sshd服务后,即可正常连接。

四、同步时间

    安装ntpdate工具

    # sudo apt-get install ntpdate

1.首先查看时区:

date -R

Tue, 17 Dec 2013 18:23:01+0800

如果要修改时区,执行sudo tzselect

2.选择区域:亚洲

sudo tzselect

Please identify a locationso that time zone rules can be set correctly.

Please select a continentor ocean.

  1) Africa

  2) Americas

  3) Antarctica

  4) Arctic Ocean

  5) Asia

#? 5

3.选择国家:中国

Please select a country.

  9) China                 26) Laos                  43) Taiwan

#? 9

4.选择时区:北京时间

Please select one of thefollowing time zone regions.

1) east China - Beijing,Guangdong, Shanghai, etc.

2) Heilongjiang (exceptMohe), Jilin

#? 1

5.确认验证:

Is the above informationOK?

1) Yes

2) No

#? 1

6.复制文件到/etc目录下

 cp   /usr/share/zoneinfo/Asia/Shanghai    /etc/localtime

7.更新时间

sudo   ntpdate   time.windows.com

五、安装YOucompleteme

1、卸载老版本vim
         sudo apt-get remove vim  
         sudo apt-get remove vim-runtime  
         sudo apt-get remove gvim  
         sudo apt-get remove vim-tiny  
         sudo apt-get remove vim-common  
         sudo apt-get remove vim-gui-common  
2、下载vim最新源码

         cd ~

         git clonehttps://github.com/vim/vim.git

3、进入vim

           cd vim

            设置Vim源码的编译属性

              ./configure--with-features=huge --enable-rubyinterp --enable-pythoninterp                         --with-python-config-dir=/usr/lib/python2.7/config-i386-linux-gnu/--enable-perlinterp   --enable-gui=gtk2--enable-cscope --enable-luainterp --enable-perlinterp --enable-multibyte   --prefix=/usr

       需要重新配置可 输入 makedistclean #清理一下上一次编译生成的所有文件

       其中参数说明如下:

       --with-features=huge:支持最大特性

       --enable-rubyinterp:启用Vim对ruby编写的插件的支持

       --enable-pythoninterp:启用Vim对python编写的插件的支持

       --enable-luainterp:启用Vim对lua编写的插件的支持

       --enable-perlinterp:启用Vim对perl编写的插件的支持

       --enable-multibyte:多字节支持 可以在Vim中输入中文

       --enable-cscope:Vim对cscope支持

       --enable-gui=gtk2:gtk2支持,也可以使用gnome,表示生成gvim

       --with-python-config-dir=/usr/lib/python2.7/config-i386-linux-gnu/指定 python 路径

       --prefix=/usr:编译安装路径

       sudo make  VIMRUNTIMEDIR=/usr/share/vim/vim74

       sudo make install

4、安装YouCompleteMe
a、 下载

git  clone  --recursive git://github.com/Valloric/YouCompleteMe

如果执行该命令没报错, 就ok了. 但是中途有可能会断掉, 可以 cd 到YouCompleteMe, 然后反复用如下命令再次进行下载:

git  submodule update --init --recursive

这个命令下载时间挺长的

b、 安装

cd ~/.vim/bundle/YouCompleteMe

./install.py --clang-completer 

成功的log如下:

-- [download 99% complete]

-- [download 100% complete]

Using libclang to provide semantic completion for C/C++/ObjC

Using external libclang: /tmp/ycm_build.CKY92s/clang+llvm-3.8.0-x86_64-linux-gnu-ubuntu-14.04/lib/libclang.so.3.8

-- Found PythonInterp: /usr/bin/python2.7 (found version"2.7.11")

-- Looking for pthread.h

-- Looking for pthread.h - found

-- Looking for pthread_create

-- Looking for pthread_create - not found

-- Looking for pthread_create in pthreads

-- Looking for pthread_create in pthreads - not found

-- Looking for pthread_create in pthread

-- Looking for pthread_create in pthread - found

-- Found Threads: TRUE 

-- Configuring done

-- Generating done

-- Build files have been written to: /tmp/ycm_build.CKY92s

Scanning dependencies of target BoostParts

[  0%] Building CXX objectBoostParts/CMakeFiles/BoostParts.dir/libs/regex/src/regex_raw_buffer.cpp.o

[  0%] Building CXX objectBoostParts/CMakeFiles/BoostParts.dir/libs/regex/src/regex_debug.cpp.o

[  1%] Building CXX objectBoostParts/CMakeFiles/BoostParts.dir/libs/regex/src/w32_regex_traits.cpp.o

[  2%] Building CXX objectBoostParts/CMakeFiles/BoostParts.dir/libs/regex/src/wide_posix_api.cpp.o

...

[100%] Building CXX objectycm/CMakeFiles/ycm_core.dir/CustomAssert.cpp.o

[100%] Linking CXX shared library/home/wuyt/mutils/debian_lenny_cfg/vim_cfg/.vim/bundle/YouCompleteMe/third_party/ycmd/ycm_core.so

[100%] Built target ycm_core

c、配置

.vimrc中加入:

" YouCompleteMe

set runtimepath+=~/.vim/bundle/YouCompleteMe

let g:ycm_collect_identifiers_from_tags_files = 1           " 开启 YCM 基于标签引擎

let g:ycm_collect_identifiers_from_comments_and_strings = 1 " 注释与字符串中的内容也用于补全

let g:syntastic_ignore_files=[".*\.py$"]

let g:ycm_seed_identifiers_with_syntax = 1                  " 语法关键字补全

let g:ycm_complete_in_comments = 1

let g:ycm_confirm_extra_conf = 0

let g:ycm_key_list_select_completion = ['<c-n>','<Down>']  " 映射按键, 没有这个会拦截掉tab, 导致其他插件的tab不能用.

let g:ycm_key_list_previous_completion = ['<c-p>','<Up>']

let g:ycm_complete_in_comments = 1                          " 在注释输入中也能补全

let g:ycm_complete_in_strings = 1                           " 在字符串输入中也能补全

let g:ycm_collect_identifiers_from_comments_and_strings = 1 " 注释和字符串中的文字也会被收入补全

let g:ycm_global_ycm_extra_conf='~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py'

let g:ycm_show_diagnostics_ui = 0                           " 禁用语法检查

inoremap <expr> <CR> pumvisible() ?"\<C-y>" : "\<CR>" |            " 回车即选中当前项

nnoremap <c-j> :YcmCompleterGoToDefinitionElseDeclaration<CR>|    " 跳转到定义处

"let g:ycm_min_num_of_chars_for_completion=2                 " 从第2个键入字符就开始罗列匹配项

其中~/.vim/bundle/YouCompleteMe 为下载 YouCompleteMeu 的路径.

六、安装NERDTree

wget http://www.vim.org/scripts/download_script.php?src_id=17123 -Onerdtree.zip

unzip nerdtree.zip 

mkdir -p ~/.vim/{plugin,doc}

cp plugin/NERD_tree.vim  ~/.vim/plugin/

cp doc/NERD_tree.txt  ~/.vim/doc/

安装好后,命令行中输入vim,打开vim后,在vim中输入:NERDTree,你就可以看到NERDTree的效果了。


0 0