Category Archives: mac os

Gtags on emacs

In a previous post about emacs etags, I received a tip from Alex Ott suggesting gtags for C/C++.


On MacOS, you can get gtags through mac ports, installing the “global” package.


To build the symbols table, it’s simple as doing:


at the root of the project.

Usage on emacs

First, you need to add a gtags-mode on emacs and tell it where to find the gtags script if gtags.el file is not installed in the default location (mac ports install it on /opt/local/share/gtags by default). On the preferences files, I added these lines:

(setq load-path (cons "/opt/local/share/gtags/" load-path))                                                                                                             
(autoload 'gtags-mode "gtags" "" t)  

Some useful commands:

  • gtags-find-tag [tag name] — this command finds the definition of tag name.
  • gtags-find-rtag [tag name] — this command finds the usage of the tag name
  • gtags-find-tag-from-here — this command is a smart version of the above. It will look up the name that is pointed by your cursor. If your cursor is on a definition, it will look for usage. On the other hand, if your cursor is on a usage, it will look for the definition.

One may wish to bind this last command to some key.


Cmake syntax highlighting for aquamacs

Aquamacs does not offer syntax highlighting for cmake files for default. To change that, download the parser from cmake website:

Then, add the following lines in the configuration file for aquamacs, usually in: ~/Library/Preferences/Aquamacs Emacs/Preferences.el

; Add cmake listfile names to the mode list.
(setq auto-mode-alist
	   '(("CMakeLists\\.txt\\'" . cmake-mode))
	   '(("\\.cmake\\'" . cmake-mode))

(autoload 'cmake-mode "~/CMake/Docs/cmake-mode.el" t)


How to solve linker dependencies on Mac OS X

I got the following error message when compiling a code, even though I’d already passed the correct include/library paths.

dyld: Library not loaded: libboost_filesystem.dylib
Referenced from: /Users/kunigami/dev/osl/build/macosx/shaders/../oslc/oslc
Reason: image not found

This happend because I built boost from source and kept it local. Thus the path to the library was not the default one. To solve this problem we have to edit the environment variable DYLD_LIBRARY_PATH, which is analogous to linux LD_LIBRARY_PATH:

export DYLD_LIBRARY_PATH=/Users/kunigami/dev/boost/lib:$DYLD_LIBRARY_PATH