Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
How to install qcachegrind (kcachegrind) on OSX Snow Leopard
SUMMARY
I like to use kcachegrind for doing profiling on my ruby code. Most of my development
is done on OSX, and while you can install kcachegrind via macports, it takes forever
because it has to build KDE, as well. Much to my surprise, the fine folks who
wrote kcachegrind also made a QT version, qcachegrind. I was able to build this on
OSX without too much effort, only having to install QT and GraphViz. Yippie!
I'm running OSX 10.6.7, with Xcode 4. My default gcc/g++ version is 4.2. I'm sure
it will build just fine on earlier versions of Xcode, but I haven't tested it.
### Download and install QT
# I installed 4.7.3 on for 10.5/10.6 from here:
# http://qt.nokia.com/downloads/qt-for-open-source-cpp-development-on-mac-os-x/
### Download and install Graphviz
# If you don't already have graphiviz (specifically the 'dot' binary), then
# install it. This is so that you can see the pretty call graphs that
# qcachegrind likes to draw.
# http://www.graphviz.org/Download_macos.php
# By default, Graphviz installs dot to /usr/local/bin/dot, which qcachgrind.app
# might not find since /usr/local/bin isn't in PATH by default (I think). In order
# to ensure that my graphs render, I created a symlink from /usr/bin/dot to /usr/local/bin/dot:
sudo ln -s /usr/local/bin/dot /usr/bin/dot
### Building qcachegrind
svn co svn://anonsvn.kde.org/home/kde/trunk/KDE/kdesdk/kcachegrind kcachegrind
cd kcachegrind/qcachegrind
# qcachegrind will only let you open up files named "callgrind.out*". Since
# I'm an adult, I created a patch that allows me to open up any file.
# You can grab the patch from this gist.
wget https://gist.github.com/raw/1029580/e93011546fa5d562fa2a4d80b2d96479276b790e/qcachegrind_filename_filter.patch
patch -p0 < qcachegrind_filename_filter.patch
# By default, qmake wanted to build an xcode project on my box. I pointed
# it at spec profile that builds using g++, and things seemed to work fine.
# You can see all the profiles available in this directory: /usr/local/Qt4.7/mkspecs
# This also managed to spit out a whole bunch of errors and warnings, yet
# everything seemed to build properly.
qmake -spec 'macx-g++'
make
# It should have generated 'qcachegrind.app'. You can put this in
# /Applications, or you can just open it directly.
open qcachegrind.app
--- qcgtoplevel.cpp (revision 1237008)
+++ qcgtoplevel.cpp (working copy)
@@ -795,7 +795,7 @@
file = QFileDialog::getOpenFileName(this,
tr("Open Callgrind Data"),
_lastFile,
- tr("Callgrind Files (callgrind.*)"));
+ tr("Callgrind Files (*)"));
loadTrace(file);
}
@@ -842,7 +842,7 @@
file = QFileDialog::getOpenFileName(this,
tr("Add Callgrind Data"),
_lastFile,
- tr("Callgrind Files (callgrind.*)"));
+ tr("Callgrind Files (*)"));
addTrace(file);
}

bucha commented Mar 1, 2013

Seems like they moved from SVN to GIT:
git clone git://anongit.kde.org/kcachegrind

bogdanmt commented Mar 6, 2013

FYI, especially for Mac users:

  1. Yes, they moved to Git, that's the link. Thank you man for posting it!
  2. The patch is no more required, because they offer now the choice "All Files () / Callgrind Files (callgrind.)" when you open files.
  3. For Mac OS X you can use QT and Graphviz binaries (there is no need of mac ports or brew); just don't forget to create that symbolic link for Graphviz.

Thanks guys! I was able to build it in minutes on 10.7.5 with

git clone git://anongit.kde.org/kcachegrind
cd kcachegrind/qcachegrind
qmake -spec 'macx-g++'; make

Copy generated qcachegrind.app to your Applications folder.

Sources:

MikeiLL commented Aug 13, 2014

Very helpful. Thank you. Took me a minute to figure out moving the qcachegrind.app. Ended up just doing it by locating the file with spotlight and option-dragging into Applications folder 'cause I couldn't remember where I had saved it and was having trouble finding it with grep - name...

@ghost

ghost commented Sep 1, 2014

Hi guys. Would it be possible for someone to provide the compiled binaries?

rchrd2 commented Aug 18, 2015

The QT link is no longer valid. Here is a new link: http://download.qt.io/official_releases/qt/4.8/4.8.7/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment