Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos 安装Valgrind时,make失败_Macos_Makefile_Valgrind_Darwin - Fatal编程技术网

Macos 安装Valgrind时,make失败

Macos 安装Valgrind时,make失败,macos,makefile,valgrind,darwin,Macos,Makefile,Valgrind,Darwin,我正试图用雪豹在Mac上安装Valgrind,但出现了一个错误。这就是我在终端上输入的内容 $ 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 这就是我得到的错误 Making all in coregrin

我正试图用雪豹在Mac上安装Valgrind,但出现了一个错误。这就是我在终端上输入的内容

$ 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
这就是我得到的错误

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

如何更正此错误?

显然,要在Macintosh上编译,valgrind需要存在文件
/usr/include/mach/mach_vm.defs
。虽然我还没有找到关于
mach_vm.defs
是XCode的一部分的具体引用,但似乎
/usr/include/mach
的大多数常用内容都是在XCode运行时安装的


如果由于某种原因无法在计算机上安装XCode,则可以从中获取该特定目录的大部分源文件。

请确保安装命令行工具

xcode-select --install

正确编译valgrind的最佳方法是使用上述答案中提到的“xcode select--install”命令。 但是,作为次优黑客,您可以通过从/usr/include/mach(创建此目录)下载以下文件来编译它:


这是一个有点肮脏的黑客行为,但如果你真的不想下载/安装大型Xcode原始文件,它应该会让你去做。

自从OSX上安装了系统完整性保护系统以来,用户,甚至不是root用户,都可以修改
/usr
。因此,修改/usr/include/mach以添加必要的文件变得不可能。现在唯一的选择是编辑makefile本身

手头的Makefile应该位于
corefrind/Makefile
,mach文件应该位于
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/
附近(用适当版本的OSX替换MacOSX10.12.sdk)

在第160行左右应该有一个名为
am\uu append\u 17
的符号(对于不同的版本,可能在其他地方)

它应该是这样的:

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
/usr/include
的每个实例替换为
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/
,使其看起来像:

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

在此之后,valgrind应该正确编译

您是否安装了Xcode?我没有Xcode,因为对于雪豹来说,获取Xcode特别困难。请参阅下面的答案。我相信它会解决你的问题。这个问题的最终状态在@Volte's Response下的评论中解释。@N0un Volte的回答不会解决我的问题。这就是问题所在。不幸的是,我遇到了另一个问题。如果我不能解决它,我会发布一个新问题。我有一个类似的问题。这个答案很有帮助,但本页上的一些评论也是如此。/usr/include/mach=/Applications/xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/includet的xcode安装位置在新的El Capitan操作系统中,甚至连sudo都无法创建目录“/usr/include”向下滚动并使用另一个答案!这更好。正确,这是Valgrind开发人员推荐的修复程序。上面的备选方案很脆弱,不能保证在将来的Xcode版本中使用。这对我来说非常有效。这应该是公认的答案。我在回答这个问题时使用的计算机已经过了测试,但是,即使它已经存在,考虑到我具体问题的性质,我怀疑这个答案是否有效。由于苹果承认的一项商业决定被误导,雪豹的一个特定版本在不支付全部开发费用的情况下无法获得Xcode。支付墙在下一个版本中被移除,但在那个版本中从未被移除;我的版本。我的解决方案是双启动Ubuntu并继续我的项目。我使用的是Mavericks和XCode 6。在我运行xcode select--install之后,它仍然在请求上面提到的defs文件,因为makefile正在/usr/include目录中查找它们。可以通过执行ln-s/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOS10.9.sdk/usr/include进行软链接,这样makefile就可以找到相关的文件。这对我来说不起作用,但它确实起到了:
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