TYPO free

home

fighting for TYPO free code

Installing KCachegrind on OSX

1 Aug 2009

This article is only relevant for users of OSX. 

Coming from a Gentoo world to OSX, now and then I want to install some software that is not available pre-built for OSX. I like to use more recent Apache 2 for local testing and I also like to use Gimp and InkScape, so I use MacPorts to fetch and compile all the Open Source goodness that is not available pre packaged on OSX. Using MacPorts we can install PHP on apache2 and have it work just as you expect it to work on a full server system (working ImageMagick etc.). I have system where I run a lot of local TYPO3 installations for testing purposes. I have several installations of dam sites running dam 1.0, dam 1.1 and dam trunk for example. I run these sites on various TYPO3 sources (4.1, 4.2, 4.3, etc.). I just name them local41, local42, local43 etc. I think every TYPO3 developer should have such a setup.

In this article I will explain how to setup MacPorts on you system and how to build KCachegrind with it. KCachegrind is a great tool to profile your code. In a following article we will discuss a use case; profiling the 'check for updated extensions' code in the extension manager. But first . . .

Get r00t

Yes, for MacPorts to install stuff into /opt/local/ you will need to use a root acount with a super secret password. If you do not yet have a root account, you can boot your OSX install DVD and set the root password there.

Fetch MacPorts

MacPorts is great because it gives you all the goodies like a 265 color capable vim, a proper ImageMagick version for your local TYPO3 installations and much more. MacPorts lives in /opt/local/. All the sources, binaries, cache etc. all live there, completely separate from OSX. So you do not need to worry about polluting your installation at all, just use what you like from /opt/local. Removing ports and MacPorts is just as easy. I mostly use the command line ports tool, but there is also a GUI for using MacPorts called 'Porticus': https://porticus.alittledrop.com/.

Install X11

MacPorts needs X11, so go ahead and install that. You can get a fresh X11 with Quartz support from xquartz.macosforge.org.

Install Xcode Tools

MacPorts fetches sources and compiles all the software itself. To be able to compile software, you will need a compiler. The XCode Tools package comes with a compiler, you can find the tools on your OSX install DVD. If you are an iPhone fanboy/girl and do app development, you will already have Xcode installed.

If you don't, go to https://www.macports.org/ and download and install the latest MacPorts version.

Read the first few chapters of the documentation. I mean it, read them! Extra karma points for people who read the docs. The documentation is very good. In a following article I will explain how to create your own port files. This is usefull if you still want to run PHP 5.2 instead of 5.3 for example.

Build KCachegrind

This is pretty straight forward, open a terminal and type the following command:

sudo port install kcachegrind 

This command will pull in all needed dependancies. It will build all the packages needed to build kcachegrind. This will take some time.

Adding /opt/local/s?bin to your path

All compiled binaries live in /opt/local/bin and /opt/local/sbin. Some applications like Gimp.app have an own launcher in your /Applications/MacPorts folder. You should add the bin dirs to your path. You can do this by adding the following line to your ~/.bash_profile

export PATH=/opt/local/bin/:/opt/local/sbin/: $PATH

I put the paths in front of the system paths so that executables in /opt/local get preference over the existing OSX executables.

Running KCachegrind

That's it. You now have a shiny new version of KCachegrind installed on OSX. To run it, open a terminal and type the following command:

kcachegrind

That will launch X11 and KCachegrind. The good news is that allmost all open source software that runs on *nix is also available on MacPorts. If there is no Port available, it's pretty easy to build a Port file.

 

Ninad Desai 9 Jun 2010, 19:17
i installed kcachegrind using macports.
i set the path in profile.
but when i try to run kcachegrind it gives me following error -

ninad:/ admin$ kcachegrind
kcachegrind: cannot connect to X server /tmp/launch-GnNOms/org.x:0

i uninstalled kcachegrind and re-installed it. It says , it installed successfully but same result.

any idea ?
Michiel 9 Jun 2010, 19:24
Hi Nidal,

Make sure you have X installed: https://xquartz.macosforge.org/trac/wiki
Commenting is closed for this item