ubuntu14.04编译gnu global 6.6.3

打算重新折腾下环境,看中了gtags ,可参考 Vim 8 中 C/C++ 符号索引:GTags 篇 ,先记录下编译过程

源码

下载并解压源码

最新的代码到官方下载页面获取 https://www.gnu.org/software/global/download.html

例如我下载的是

 wgets http://tamacom.com/global/global-6.6.3.tar.gz

下载后解压并进入目录

依赖

先安装依赖

sudo apt-get build-dep global
sudo apt-get install libncurses5-dev libncursesw5-dev

配置

再配置,配置的时候可以使用--prefix指定安装目录,考虑到我后续需要在无sudo权限的机器上使用,这里执行安装到用户目录下的usr

./configure --prefix=/home/zhuangqiubin/usr

编译

直接调用make即可

make

本以为make会很顺利,没想到出来一个报错

find.c: In function ‘findassign’:
find.c:557:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
  for (int i = 0; opts[i] != NULL; i++) {
  ^
find.c:557:2: note: use option -std=c99 or -std=gnu99 to compile your code
make[2]: *** [find.o] 错误 1
make[2]:正在离开目录 `/home/zhuangqiubin/usr/tools/global-6.6.3/gtags-cscope'
make[1]: *** [all-recursive] 错误 1
make[1]:正在离开目录 `/home/zhuangqiubin/usr/tools/global-6.6.3'
make: *** [all] 错误 2

懒得改编译参数,直接改下源码算了

vim gtags-cscope/find.c +557

    for (int i = 0; opts[i] != NULL; i++) {

改为

    int i;
    for (i = 0; opts[i] != NULL; i++) {

重新执行一次make

安装

make install

安装后可找到

 ~/usr/bin/global
 ~/usr/bin/gtags 
 ~/usr/bin/gtags-cscope

也可以确认下版本

 global --version

global (GNU GLOBAL) 6.6.3
Powered by Berkeley DB 1.85.
Copyright (c) 1996-2018 Tama Communications Corporation
License GPLv3+: GNU GPL version 3 or later <http://www.gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

本文链接:https://www.cnblogs.com/zqb-all/p/12005654.html

猜你喜欢

转载自www.cnblogs.com/zqb-all/p/12005654.html