user1017485
user1017485

Reputation: 719

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?

Upvotes: 38

Views: 120228

Answers (6)

Alexander Yalunin
Alexander Yalunin

Reputation: 419

For macOS Big Sur / Monterey:

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

Upvotes: 12

joshua.thomas.bird
joshua.thomas.bird

Reputation: 705

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.

Upvotes: 35

Marco Montalto M.
Marco Montalto M.

Reputation: 351

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

Upvotes: 13

rgk
rgk

Reputation: 866

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

Upvotes: 20

robbie_c
robbie_c

Reputation: 2458

You may find it easier to use something like macports. How to install that is probably beyond the scope of this question, but they have a page dedicated to it on their site.

Once you have macports installed, you need to type:

sudo port install valgrind +universal

As you say you don't have any experience of command lines, let's just briefly go through the different parts of this command:

  • sudo means the rest of the command will run as root, and will ask for your password. This is needed for the installer to have the correct permissions
  • port is the command line tool for managing macports
  • install is a command for port. Try port help to see a list of commands.
  • valgrind tells macports what it should be installing
  • +universal is a variant. This tells macports to configure valgrind to support 32 bit and 64 bit support.

Upvotes: 3

Mankarse
Mankarse

Reputation: 40633

The core process is pretty simple:

Make sure you are in the correct directory.

First run:

./configure

when that is finished, run:

make

at this point you will need to su into root (this is relatively tricky to do, see the note at the end). As root, run:

make install

When this is finished you will have a working valgrind installation. Test it by running

valgrind ls -l

To su into root, you will need to have set up a root account. If you have not done this in the past, see the instructions from apple here.

To perform the actual su, you will first have to be running an account with administrator privileges. If you are not already doing so, you can switch users with the following:

su admin

where admin is the name of an user with administrator privileges (you will need to enter the password for this account). From there, you can then run su to go into root:

su

You will need to enter the root password that you set up earlier.

Upvotes: 3

Related Questions