Valgrind on Mac OS X 10.10 Yosemite

· by Mario Ranftl · 313 words, 2 min ·  c  programming

You want to hack with C and Valgrind on OS X 10.10 Yosemite? Well, you’ll definitely run into problems getting it for your very platform, as there is no official stable release out there yet. Consequentially these is no receipt for Homebrew (which is great anyways, get it!), hence you need to manually build that nifty tool from the latest trunk SVN repository.

Here’s how to do that (needs installation of Xcode’s Command Line Tools):

# Check out their repo...
$ svn co svn:// valgrind-trunk
# and hop into it.
$ cd valgrind-trunk

# You need to have autoconf and automake installed to build Valgrind
# This example uses Homebrew to install these dependencies
# (MacPorts should also work)
# (Permission error? add sudo!)
$ brew install automake
$ brew install autoconf

# run in valgrind-trunk
$ ./

# Tricky, there are some hard wired paths in the Valgrind sources.
# You need to symlink the mach folder in your XCode SDK to /usr/include/mach
# Be sure to use the proper Xcode SDK "MacOSX10.10.sdk" in the path!
$ ln -sv /Applications/ /usr/include/mach

# Run configure + set install paths in valgrind-trunk
$ ./configure --prefix=/usr/local

# Run Make and make install (permission error? add sudo!) in valgrind-trunk
$ make
$ make install

# Check it works
$ valgrind --version

Still on OS X 10.9 Mavericks? Then you might want to check out Calvin’s great How-To.
Background: Currently relearning C the hard way.

EDIT 2015-01-23: Seems like a lot of people assert that Valgrind is completely supported on Mac OS X (although unstable trunk build) and works out of the box (like in Linux). Both assertions are not true! Valgrind will show false positive memory leaks in OS X’s system libraries (these are out of your control), unless you define a suppression file. Have a look at Taras’ How-To to generate such a file!

  About the author

Mario Ranftl is a dedi­cated Aus­trian senior soft­ware en­gi­neer with con­sider­able ex­peri­ence in a range of soft­ware develop­ment en­viron­ments and a special­ization in web tech­nologies. He con­trib­utes to Open Source pro­jects on GitHub and loves to cre­atively solve chal­lenging prob­lems. You can easily reach him via Email.

  Share and subscribe