Aim
- This post talk about how to set up Spacemacs on ubuntu as a c++ IDE
Prerequisite
- Install emacs from source
$ sudo apt install build-essential checkinstall
$ sudo apt-get build-dep emacs24
# Download the source code, extract it
$ tar zxvf emacs-25.1.tar.xz
$ cd emacs-25.1
$ ./configure --prefix=/usr/local/emacs/25.1
$ make -j 4
$ sudo mkdir -p /usr/local/emacs/25.1
$ sudo make install
$ vim ~/.bashrc
# insert the following line
$ export PATH=/usr/local/emacs/25.1/bin:$PATH
$ cd ~
$ mv .emacs.d .emacs.d.bak
$ git clone https://github.com/syl20bnr/spacemacs ~/.emacs.d
$ emacs --insecure
- Install GNU Global from source
$ tar zxvf globalxxx.tar.xz
$ cd global
$ ./configure --prefix=/usr/local/global/xx.xx
$ make -j 4
$ sudo mkdir -p /usr/local/global/xx.xx
$ sudo make install
$ vim ~/.bashrc
# insert the following line
$ export PATH=/usr/local/global/xx.xx/bin:$PATH
- Install cscope from source
$ tar zxvf cscopexxx.tar.xz
$ cd cscope
$ ./configure --prefix=/usr/local/cscope/xx.xx
$ make -j 4
$ sudo mkdir -p /usr/local/cscope/xx.xx
$ sudo make install
$ vim ~/.bashrc
# insert the following line
$ export PATH=/usr/local/cscope/xx.xx/bin:$PATH
$ cd ~/Downloads/SoftwareInstall
$ git clone https://github.com/Valloric/ycmd.git
$ sudo apt-get install build-essential cmake python-dev
$ cd ycmd
$ git submodule update --init --recursive
$ ./build.py --clang-completer
$ vim ~/.emacs.d/layers/+tags/cscope/packages.el
# change the command prefix from g to c
- Update .spacemacs
- Download file spacemacs from here
- compare the downloaded file with ~/.spacemacs, you will found that you have to upgrade some layers, ycmd location and c++ indent information.
- DONE
How to use
- View gtags layer for information about how to use gtags
- View cscope layer for information about how to use cscope
- Download from here:
- prepareClang.sh
- prepareEmacsTag.sh
- Put them to /usr/bin
- Go to your c++ project root
- ./prepareEmacsTag.sh
- use spacemacs to view source code under the project root
- DONE
What you have now
- You can do code navigation by gtags and cscope
- You can have auto-complete and syntax checking accomplished by ycmd backend for c++
沒有留言:
發佈留言