How to build and install Valgrind on Mac?

On MacOS High Sierra

If you have the following error message:

brew install valgrind
valgrind: This formula either does not compile or function as expected on macOS
versions newer than Sierra due to an upstream incompatibility.

Fix

(1) To correctly install it, first, type the following command at the Terminal (which opens Valgrind’s formulae)

brew edit valgrind

And change the URL in head section

https://sourceware.org/git/valgrind.git

to

git://sourceware.org/git/valgrind.git

(2) Do an update for Homebrew:

brew update

(3) Finally, use the following command to install Valgrind from the HEAD:

brew install --HEAD valgrind

Sources

  • https://www.gungorbudak.com/blog/2018/04/28/how-to-install-valgrind-on-macos-high-sierra/
  • https://github.com/Homebrew/homebrew-core/issues/18998

Recommended:

Use brew: brew install valgrind

Manual Install:

Here's what worked on my Mac (10.6). Double-check you have the latest version, then change into the uncompressed directory

cd /users/(insert username here)/downloads/valgrind-3.17.0

I suggest you do as another posted and read the readme.

nano README

Commence the build; /usr/local is the place on the filesystem that the program will be installed to. There are many arguments like prefix that are available to customize the installation to your particular system if it doesn't work by default. Normally just using ./configure works perfectly well though.

./configure --prefix=/usr/local

make

sudo make install

Or you could probably get it from fink or macports or homebrew.


You can install it through brew for Mac:

brew install valgrind

You might have to manually link the entry to /usr/local/bin as brew refused to do it in my case:

$ ln /usr/local/Cellar/valgrind/3.8.1/bin/vgdb /usr/local/bin/vgdb
ln: /usr/local/bin/vgdb: Permission denied
$ sudo ln /usr/local/Cellar/valgrind/3.8.1/bin/vgdb /usr/local/bin/vgdb

Tags:

Build

Valgrind