macos - 如何使用 Homebrew 在 macOS Mojave(10.14) 上安装 Valgrind?

标签 macos homebrew valgrind memory-leak-detector

我尝试使用 brew install Valgrind 安装 Valgrind 并得到:

valgrind: This formula either does not compile or function as expected
on macOS versions newer than Sierra due to an upstream
incompatibility. 
Error: An unsatisfied requirement failed this build.

我尝试了brew install --HEAD Valgrind

相反,在成功安装依赖项 autoconfautomakelibtool 后,当它尝试安装 valgrind 时,我收到配置错误:

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)

我的操作系统是 macOS Mojave(10.14),这是否意味着我目前无法使用 Homebrew 安装正常运行的 Valgrind?

最佳答案

基于 this patch 的(相当痛苦的)从源代码安装解决方法, this postthis answer .

$ git clone https://github.com/Echelon9/valgrind.git
$ cd valgrind
$ git checkout feature/v3.14/macos-mojave-support-v2
$ ./autogen.sh
$ ./configure --prefix=/where/you/want/it/installed --enable-only64bit
$ make

如果您收到以下错误:没有规则来创建目标'/usr/include/mach/mach_vm.defs',您将需要运行xcode-select --install。如果您还没有安装 Xcode,则可能需要从应用程序商店安装 Xcode。完成后,您需要编辑 coregrind/Makefile:

搜索:

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

仔细检查以下文件夹是否存在后,在每一行添加前缀:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk

最终结果应该是:

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

现在再次运行make,应该可以找到包含的内容。但这并不一定意味着它会编译。我收到以下错误:

vg_preloaded.c:136:19: error: expected ';' before 'const'
 __private_extern__ const char *__crashreporter_info__ = "Instrumented by Valgrind " VERSION;

解决此问题的方法是添加以下行:

#define __private_extern__ extern

到以下文件:

  • coregrind/m_syscall.c
  • coregrind/m_syswrap/syswrap-darwin.c
  • coregrind/vg_preloaded.c

最后,您需要祈祷没有其他错误出现:

$ make
$ make install

关于macos - 如何使用 Homebrew 在 macOS Mojave(10.14) 上安装 Valgrind?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52732036/

相关文章:

ruby - 如何修改 Homebrew 的 PATH?

c - 将结构数据复制到链表时出现段错误

java - 如何为 SWT Java 应用程序设置高质量的 OSX 停靠栏图标

ruby - ruby 2.3.1 缺少库

Mac 上 Java 安装失败

homebrew - 在 sonatype nexus 服务器中哪里可以找到日志文件,通过在 osx 上安装 brew

macos - Rust、OpenSSL、solana-test-validator 库未加载问题

c++ - 不同机器上的不同 Valgrind 输出

c++ - Valgrind 对 FILE 的读取无效*

python - 错误 : Could not find a version that satisfies the requirement webdriver (from versions: )