Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

make fails while installing Valgrind

I'm trying to install Valgrind on a Mac with Snow Leopard but am getting an error. This is what I'm typing into Terminal.

$ curl -O http://valgrind.org/downloads/valgrind-3.8.1.tar.bz2
$ md5sum valgrind-3.8.1.tar.bz2
$ tar -xjvf valgrind-3.8.1.tar.bz2
$ cd valgrind-3.8.1
$ ./configure
$ make

This is the error I get.

Making all in coregrind
make[2]: *** No rule to make target `/usr/include/mach/mach_vm.defs', needed by `m_mach/mach_vmUser.c'.  Stop.
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

How can I correct this error?

like image 832
Jack Stout Avatar asked Nov 16 '12 17:11

Jack Stout


Video Answer


4 Answers

Make sure to install the command line tools.

xcode-select --install
like image 57
Volte Avatar answered Sep 30 '22 14:09

Volte


The best way to get valgrind compiled properly is to use the 'xcode-select --install' command as mentioned in the above answer. However, as sub-optimal hack, you can get it compiled by downloading the following files from OSX /mach source into /usr/include/mach (create this directory):

mach_vm.defs    
task.defs
thread_act.defs
vm_map.defs

It's a slightly dirty hack, but it should get you going if you really don't want to download/install the large Xcode original files.

like image 37
Pete855217 Avatar answered Sep 30 '22 15:09

Pete855217


Apparently, to compile on a Macintosh, valgrind needs the file /usr/include/mach/mach_vm.defs to be present. While I haven't been able to find specific references to mach_vm.defs being part of XCode specifically, it seems that most of the usual contents of /usr/include/mach are installed when XCode is.

If for some reason you can't install XCode on your machine, you can get most of the source files for that particular directory from this part of apple's open source website.

like image 27
Dan Avatar answered Sep 30 '22 14:09

Dan


Ever since the System Integrity Protection system was put in place on OSX, the user, not even as root, can modify /usr. Thus, modifying /usr/include/mach to add the necessary files becomes impossible. The only alternative is now to edit the makefile itself.

The Makefile at hand should be located at coregrind/Makefile, and the mach files should be located near /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/ (replace MacOSX10.12.sdk with the appropriate version of OSX).

There should be a symbol named am__append_17 defined around line 160 or so (might be elsewhere for different versions).

It should look something like this:

am__append_17 = \
    /usr/include/mach/mach_vm.defs \
    /usr/include/mach/task.defs \
    /usr/include/mach/thread_act.defs \
    /usr/include/mach/vm_map.defs

Replace each instance of /usr/include with /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/, so that it looks like:

am__append_17 = \
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/mach/mach_vm.defs \
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/mach/task.defs \
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/mach/thread_act.defs \
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/mach/vm_map.defs

After this, valgrind should compile properly

like image 21
Lux Avatar answered Sep 30 '22 14:09

Lux