Pages - Menu

標籤

AWS (1) bash (1) Boost (2) C (2) CMake (2) Concurrency_Programming (3) CPP (37) Database (2) DNS (1) Docker (4) Docker-Compose (1) ELK (1) emacs (4) gcp (1) gdrive (1) git (1) gitbash (2) gitlab (1) kvm (4) Linux (5) MT4 (4) MT5 (4) Multicast (2) MySQL (2) Nijatrader8 (1) OpenCV (1) Python (4) QT5 (1) R (1) rdp (3) screenshot (1) ssh (3) Tabnine (1) TCP (1) TensorFlow (1) Tools (12) Ubuntu_1904 (11) Ubuntu_20_04 (5) UDP (1) VS2010 (1) VS2015 (1) VS2019 (1) WebServer (1) Win10 (1) winmerge (1) WSL (1) xrdp (1)

搜尋此網誌

2018年6月8日星期五

Spacemacs as c++ IDE

Aim

  • This post talk about how to set up Spacemacs on ubuntu as a c++ IDE

Prerequisite

Steps

  • 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
    
  • Add emacs to PATH
  • $ vim ~/.bashrc
    # insert the following line
    $ export PATH=/usr/local/emacs/25.1/bin:$PATH
    
  • Install spacemacs
  • $ 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
    
  • Add Global to PATH
  • $ 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
    
  • Add cscope to PATH
  • $ vim ~/.bashrc
    # insert the following line
    $ export PATH=/usr/local/cscope/xx.xx/bin:$PATH
    
  • Install YCMD
  • $ 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
    
  • Fix a bug for spacemacs
  • $ 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++

沒有留言:

發佈留言