Install kcachegrind on MacOSX with ports

Well, you don't want to install kcachegrind with port.

$ sudo port search cachegrind
kcachegrind @0.4.6 (devel)
    KCachegrind - Profiling Visualization

Because building KDE takes hours, and you wont need it other than for cachegrind. But there's a QT variant coming with kcachegrind, called qcachegrind. Maybe ports wants to use this variant. Or not, because kdelibs3 is listed as dependency.

$ sudo port info kcachegrind

kcachegrind @0.4.6, Revision 1 (devel) Variants: universal

Description: KCachegrind visualizes traces generated by profiling, including a tree map and a call graph visualization of the calls happening. It's designed to be fast for very large programs like KDE applications. Homepage:

Library Dependencies: kdelibs3
Platforms: darwin
License: unknown

sudo port install kcachegrind
--->  Computing dependencies for kcachegrind
Error: Unable to execute port: Can't install qt3 because conflicting ports are installed: qt4-mac

So there's an artificial conflict, qt4-mac is better than qt3, and you can easily build qcachegrind with qt4-mac.

port deps:

sudo port install qt4-mac graphviz

This needed only one minute

Go to Download the source tarball


tar xfz ~/Downloads/kcachegrind-0.7.4.tar.gz
cd kcachegrind-0.7.4/
cd qcachegrind/
qmake -spec 'macx-g++'
mv /Applications/
open /Applications/

And it works.

Just gprof and gcc profiling via -pg does not work. But this is another story. So far I use XCode Instruments with the Time Profiler. See the next post Using kcachegrind on potion

On linux I did the same, just qmake without arg and

sudo cp qcachegrind /usr/local/bin/

1 Comment

Excellent. Worked immediately ! Thanks !!!

I plan to use qcachegrind as complement to Devel-NYTProf (nytprofcg)

Don't forget to run this before expanding the tarball:
$ xattr -d kcachegrind-0.7.4.tar.gz

Don't forget too to "port selfupdate" before installing gt4-mac, graphviz and qmake

About Reini Urban

user-pic Working at cPanel on cperl, B::C (the perl-compiler), parrot, B::Generate, cygwin perl and more guts, keeping the system alive.