Ivan Čukić

Using GNU Global for local source code indexing

If you are not a fan of using an online source code searching tool like lxr.kde.org, but are still tired of grepping for a particular class or function in the KDE Frameworks (and other projects as well), you might find the GNU Global tool quite useful.

It is similar to ctags and cscope, but IMO it works nicer.

You can index your desired project (or everything at once) simply by calling gtags in the project’s root. Later, in order to incrementally update the tags files, you can just call global -u.


There are a few options when searching already indexed source tree that I find most useful:

  • no options at all :) – searches for the specified symbol definitions
  • -r – searches for usages of the specified symbol
  • --result grep – apart from listing the contained files, also prints out the line contents.

For other available options, just check out the man page.

Loading comments...