Emacs 配置 C/C++ 开发环境, ggtags 失败

安装gun global 安装ggtags 但是就是不成功,哪位能告诉下详细步骤,谢谢

报错信息如下:

Error running timer ‘ggtags-highlight-tag-at-point’: (file-error “Searching for program” “No such file or directory” “global”)

Error running timer 'ggtags-highlight-tag-at-point': (file-error "Searching for program" "No such file or directory" "global")

提示你的 Emacs 找不到 global,你得安装 GNU Global,并确保 global 在你的 PATH 中。

估计 ggtags 主页上有详细步骤。

(add-to-list 'exec-path “/path/to/global/bin”))

谢谢,我试试哈

谢谢,我试试,找的都没看到添加path,真坑

实际上使用包管理安装global的话不需要另外添加path

直接源码安装的,太复杂的不大会啊😊

官网源码安装不行怎么破,谢谢

讲道理源码装才是最复杂的吧:joy: 用包管理装的意思是 mac上用homebrew,linux上用相应包管理,如debian/ubuntu 用apt-get,centos用yum,arch用pacman这样 :joy:

先确认安装后global命令是否可用,可用则添加whereis global的结果到 exec-path

还是没搞定啊 emacs 是25.1的

我的 Emacs 配置在:

其中 gtags 配置:

(require 'ggtags)

;; ggtags settings
;; Activate cygwin mount for gtags CDPATH issue on W32
(cond ((eq window-system 'w32)
       (require 'cygwin-mount)
       (cygwin-mount-activate)))
(setq ggtags-global-ignore-case t)
(setq ggtags-sort-by-nearness t)
(setq ggtags-global-ignore-case nil)
;; let ggtags use split-window with is redefined by ecb mode
;;(setq ggtags-split-window-function 'split-window-below)

;; close grep window and done ggtags navigation when type C-g
;; but some times it will close all the ecb windows, so remove this advice.
;; (advice-add 'keyboard-quit :before #'kimim/kill-grep-and-ggtags-done)
(defun kimim/recenter()
  (interactive)
  (recenter))

(advice-add 'pop-tag-mark :after #'kimim/recenter)
;;(advice-add 'next-error :after #'kimim/recenter)
;;(advice-add 'previous-error :after #'kimim/recenter)

首先确保安装了 global,如果安装了global 还出现这个问题,应该是启动 Emacs 的 PATH 环境变量设置不对,可以在 Emacs 里运行 Shell 命令:

echo $PATH

看看PATH 里是否包含了global 所在目录,如果没有,请在Emacs config 里加入:

(setenv "PATH" (concat ".:/usr/local/bin" (getenv "PATH")))
(add-to-list 'exec-path "/usr/local/bin/")

我的环境里,运行:

which global

输出为:

/usr/local/bin/global