How to build and install Valgrind on Mac?

I am on Mac OS X using codeblocks 10.05

I downloaded Valgrind, and extracted a folder. I am completely lost from there, and have no idea how to build it.

I do not know ANY terminal/console commands and am generally new to programming, so I have no idea how to "build" or "compile" it. I just have a folder called Valgrind with a bunch of random files in it.

Could someone please tell me how to proceed? I already checked the website/documentation but it didn't really give me installation instructions, just usage instructions.

Thanks

PS: I know I already posted this question, but the previous question was shut down, for being too vague. I reposted this one with more info.

PSS: All that I am basically asking is what do I do to install Valgrind right after I download it from the website and extract the files?


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

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

For macOS Big Sur / Monterey:

brew tap LouisBrunner/valgrind
brew install --HEAD LouisBrunner/valgrind/valgrind