34

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?

Andrew Marshall
  • 95,083
  • 20
  • 220
  • 214
user1017485
  • 679
  • 1
  • 8
  • 16
  • @tjm sorry ill remove the "shouting". I don't really understand what you mean by detail. All Im asking is - I have downloaded Valgrind, what do I do next? Mankarse I didn't know that, thank you for the info :) – user1017485 Nov 12 '11 at 02:48
  • 1
    There is information on how to install Valgrind in the official documentation. [link](http://valgrind.org/docs/manual/dist.install.html) – Dennis Nov 12 '11 at 02:50
  • 2
    Look at the `README` file in the directory that came out of the archive when you extracted it. That file has instructions on how to configure and build, so give that a try. – David Alber Nov 12 '11 at 02:51
  • Thank you :) The README file says to run "make", but I can't find a file named "make". Do you know what to do? – user1017485 Nov 12 '11 at 02:54
  • 3
    With all due respect, asking how to build and install `valgrind` without knowing your way around the `bash` shell or knowing how to use `sudo` is like trying to program without learning to use a text editor. You're skipping too many steps. – Mike DeSimone Nov 12 '11 at 03:07
  • If you know that little about using the command line, you need to read a tutorial on using it. Valgrind will be useless if you don't understand how to use the command line. – Andrew Marshall Nov 12 '11 at 03:08
  • @Mike DeSimone Duly noted :) Could you maybe recommend me a good tutorial for command line? Because I am generally good at programming, just not familiar with command line – user1017485 Nov 12 '11 at 03:39
  • [Learning the bash shell](http://shop.oreilly.com/product/9780596009656.do) and [UNIX in a Nutshell](http://shop.oreilly.com/product/9781565924277.do) are what comes to mind. – Mike DeSimone Nov 12 '11 at 04:27
  • 4
    Questions related to tools that developers use are on topic here, and people _do_ often need to use a newer version of Valgrind to get around bugfixes or get access to new features. The comments related to the OP's command line proficiency aren't really constructive. – Tim Post Nov 13 '11 at 16:17

6 Answers6

33

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.

ZygD
  • 22,092
  • 39
  • 79
  • 102
joshua.thomas.bird
  • 676
  • 1
  • 8
  • 22
  • 4
    I don't recommend using `./configure --prefix=/usr/bin` for other users. I did this and the test in README didn't work (the system didn't have `valgrind` in its path). Just using plain `./configure` worked well for me. – Chris Redford May 22 '12 at 19:26
  • 2
    I had a similar experience. using `--prefix=/usr/bin`made valgrind unavailable in system path, but leaving out that `--prefix` did. – RDK Feb 18 '13 at 21:47
  • @Soonts There is no "correct prefix", you could install it anywhere you like. – joshua.thomas.bird Nov 11 '17 at 13:50
  • @joshua.thomas.bird Apparently, the install script included in valgrind appends “bin” to the end of the prefix you specify. If you specify `--prefix=/usr/bin`, it will be installed in `/usr/bin/bin`, and that’s why I think it’s not correct. – Soonts Nov 11 '17 at 13:59
  • Just realized you're totally right. I must've made a typo 7 years ago and not known. – joshua.thomas.bird Nov 11 '17 at 14:03
  • @joshua.thomas.bird They might have updated their install script in that 7 years. – Soonts Nov 11 '17 at 14:05
  • Well I've updated the answer to reflect that, and also put a little more info about config options in case anyone else runs into similar things. – joshua.thomas.bird Nov 11 '17 at 14:08
  • 6
    Dear joshua, for some tragic reason, brew appears to be unable to install it on my MacOSX Mojave `10.14.6` , and says : `valgrind: This formula either does not compile or function as expected on macOS versions newer than High Sierra due to an upstream incompatibility.` – A P Jo Sep 22 '20 at 06:58
21

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
waldyrious
  • 3,683
  • 4
  • 33
  • 41
rgk
  • 858
  • 16
  • 28
  • 1
    Seems like you might have to install it from head to get this to work, [as detailed here](http://stackoverflow.com/a/27408219/26510) – Brad Parks Oct 14 '15 at 14:47
  • It seems your directory permissions are not correct. Homebrew should be able to write to your /usr/local without sudo. See https://github.com/Homebrew/legacy-homebrew/issues/19670. – Yongwei Wu Nov 19 '16 at 12:39
  • I don't know why using brew is not the accepted answer for "How do I install X on a Mac." – MikeF Sep 20 '17 at 00:07
  • @BradParks installing from HEAD worked, but on my machine I get `configure: error: Valgrind works on Darwin 10.x, 11.x, 12.x, 13.x, 14.x, 15.x, 16.x and 17.x (Mac OS X 10.6/7/8/9/10/11 and macOS 10.12/13)` running macOS Mojave Version `10.14.3` – greg Apr 29 '19 at 21:48
  • I haven't tried it, but [this post on stackoverflow](https://stackoverflow.com/q/52732036/26510) suggests a solution, @GregDegruy – Brad Parks Apr 30 '19 at 01:03
13

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

9

For macOS Big Sur / Monterey:

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

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.
robbie_c
  • 2,428
  • 1
  • 19
  • 28
3

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.

Mankarse
  • 39,818
  • 11
  • 97
  • 141
  • Running make gives: "# This is a generated file, composed of the following suppression rules:" > default.supp echo "# " exp-sgcheck.supp xfree-3.supp xfree-4.supp darwin10-drd.supp darwin10.supp >> default.supp cat exp-sgcheck.supp xfree-3.supp xfree-4.supp darwin10-drd.supp darwin10.supp >> default.supp cat: exp-sgcheck.supp: No such file or directory cat: xfree-3.supp: No such file or directory cat: xfree-4.supp: No such file or directory cat: darwin10-drd.supp: No such file or directory cat: darwin10.supp: No such file or directory make: *** [default.supp] Error 1 What am I doing wrong? – user1017485 Nov 12 '11 at 03:20
  • This is expected behaviour (I can't test this right at the moment, but I remember seeing similar messages when I ran `make`). Run `make install` and see if it works. – Mankarse Nov 12 '11 at 03:24
  • make install gives me another bunch of errors When I test it using valgrind ls -l It says valgrind: command not found – user1017485 Nov 12 '11 at 03:37