wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-add-repository "<relevant 'deb http://...' text from https://apt.llvm.org>"
sudo apt update
sudo apt install clang-<latest-version>
sudo apt install libclang-<latest-version>-dev
# may need to install llvm-<latest-version>, llvm-<latest-version>-runtime
Also may have to fix what llvm-config
points to. Do this.
sudo ln -s /usr/lib/llvm-<latest-version>/bin/llvm-config /usr/local/bin/llvm-config
# Commands in Ubuntu terminal
git clone --recursive https://github.com/Andersbakken/rtags.git
cd rtags
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 .
make
sudo make install
Note that you may have to create a symbolic link sudo ln -s `which llvm-config-<latest-version>` /usr/local/bin/llvm-config
for llvm-config to be found.
add the following file to /etc/systemd/user/rdm.socket
(alt. ~/.config/systemd/user/rdm.socket
)
[Unit]
Description=RTags daemon socket
[Socket]
ListenStream=%h/.rdm
[Install]
WantedBy=multi-user.target
add the following to /etc/systemd/user/rdm.service
(alt. ~/.config/systemd/user/rdm.service
)
[Unit]
Description=RTags daemon
Requires=rdm.socket
[Service]
Type=simple
ExecStart=/usr/local/bin/rdm --log-file=%h/.rtags/rdm.log --data-dir=%h/.rtags/rtags-cache --verbose --inactivity-timeout 300
Enable the socket service
systemctl --user enable rdm.socket
systemctl --user start rdm.socket
After rtags’ install you should have a script gcc-rtags-wrapper.sh
script somewhere on path. You will need to use this wrapper to properly invoke gcc, g++ for use with rtags. To do this run:
for c in cc c++ gcc g++; do
ln -s `which gcc-rtags-wrapper.sh` "$HOME/.local/bin/$c";
done
Note you may need to add the line
export PATH="$HOME"/.local/bin:$PATH
at the end of your .bashrc
and potiential run mkdir ~/.local/bin
prior to the for loop.
This should make invocations of gcc
, g++
to use a symlink to the gcc wrapper script.
Just make sure $HOME/.local/bin
appears first on path.
To confirm this run
which -a g++
which should response with
$HOME/.local/bin/g++
/usr/bin/c++
(note that you may need to run hash -r
first before running this check for bash to clear cache)
just create a compile_commands.json
file
then use RTags to index your code
rc -J ./compile_commands.json
note that you may first need to run rdm &
https://eklitzke.org/using-emacs-and-rtags-with-autotools-c++-projects
has more info
also note that rtags will not work for projects under the /tmp
directory.