如何使用 Homebrew 在 macOS Catalina (10.15) 上安装 Valgrind?

Moc*_*chi 30 macos homebrew valgrind memory-leak-detector macos-catalina

我尝试使用命令“brew install valgrind”安装 Valgrind,我收到一条消息:

“valgrind:由于上游不兼容,此公式无法在比 Sierra 更新的 macOS 版本上按预期编译或运行。错误:未满足的要求使此构建失败。”

我还尝试在代码的头部部分“brew edit valgrind”并用“git://sourceware.org/git/valgrind.git”替换“sourceware.org/git/valgrind.git”,然后在Iterm上写“ brew install --HEAD valgrind“但它给了我:

Last 15 lines from /Users/m/Library/Logs/Homebrew/valgrind/02.configure:
checking for gcc-ar... no
checking for perl... /usr/bin/perl
checking for gdb... /no/gdb/was/found/at/configure/time
checking dependency style of clang... none
checking for diff -u... yes
checking for clang option to accept ISO C99... none needed
checking for a supported version of gcc... ok (clang-11.0.0)
checking build system type... x86_64-pc-darwin
checking host system type... x86_64-pc-darwin
checking for a supported CPU... ok (x86_64)
checking for a 64-bit only build... yes
checking for a 32-bit only build... no
checking for a supported OS... ok (darwin)
checking for the kernel version... unsupported (19.0.0)
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)

READ THIS: https://docs.brew.sh/Troubleshooting
Run Code Online (Sandbox Code Playgroud)

小智 38

请参阅https://github.com/LouisBrunner/valgrind-macos/

要么尝试

brew tap LouisBrunner/valgrind
brew install --HEAD LouisBrunner/valgrind/valgrind
Run Code Online (Sandbox Code Playgroud)

或者从源代码编译它,如果上述方法不起作用。(但他们最近应该已经修复了上述方法。)

git clone https://github.com/LouisBrunner/valgrind-macos.git
cd valgrind-macos
./autogen.sh
./configure --prefix=/where/you/want/it/installed --enable-only64bit
make 
sudo make install
Run Code Online (Sandbox Code Playgroud)

享受!

  • 今天来自 github 的版本似乎有一些改进。我按照此处的说明构建了它,并进行了一些更改: 1. 不需要步骤 5。 2. 在步骤 3、4 和 6 中不需要 sudo。 到目前为止,它似乎在 Catalina 10.15.4 上运行良好。 (2认同)
  • 它不适用于 macOS 12.3。它说“配置:错误:Valgrind 适用于 Darwin 10.x-20.x(Mac OS X 10.6-10.11 和 macOS 10.12-11.0)” (2认同)