Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save justfalter/1029580 to your computer and use it in GitHub Desktop.
Save justfalter/1029580 to your computer and use it in GitHub Desktop.
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);
}
@schmunk42
Copy link

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
Copy link

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...

Copy link

ghost commented Sep 1, 2014

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

@rchrd2
Copy link

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/

Copy link

ghost commented Jun 8, 2018

A couple other changes for qmake:

You probably won't find this in the path anymore. On my system it ended up in /usr/local/Cellar/qt/5.11.0/bin
Do not run it using the -spec. This is outdated and no longer supported. Simply run qmake followed by make

@ShashankVijay
Copy link

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

Invalid too

@Raphlecrabe
Copy link

vn: E170013: Unable to connect to a repository at URL 'https://svn.code.sf.net/p/netpbm/code/stable'
svn: E230001: Server SSL certificate verification failed: certificate has expired
Error: qcachegrind: Failed to download resource "netpbm"
Failure while executing; svn checkout https://svn.code.sf.net/p/netpbm/code/stable /tmp/rmonacho/Homebrew/Caches/netpbm--svn --quiet -r 4328 exited with 1. Here's the output:
svn: E170013: Unable to connect to a repository at URL 'https://svn.code.sf.net/p/netpbm/code/stable'
svn: E230001: Server SSL certificate verification failed: certificate has expired

I have this kind of errors when I install via homebrew. How can I fix it ?

@justfalter
Copy link
Author

@Raphlecrabe The homebrew formula for netpbm needs to be updated to change the URL from https://svn.code.sf.net/p/netpbm/code/trunk to https://svn.sourceforge.net/p/netpbm/code/trunk.
the error says that the certificate could not be validated. The cert being returned was issued June 22, 2022, and is only valid for svn.sourceforge.net and *.svn.sourceforge.net domains, not svn.code.sf.net.

I suggest filing an issue w/ https://github.com/Homebrew/homebrew-core/issues ..

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