AllenCheng.Blog

Allen Cheng’s Personal Blog Site

“Anyone who stops learning is old, whether at twenty or eighty. Anyone who keeps learning stays young. The greatest thing in life is to keep your mind young.”

—Henry Ford

C/C++ Valgrind MacOS Solution -Docker

C/C++ Valgrind MacOS Solution -Docker

Intel X86 CPU:

Valgrind Macos Project on Github:

https://github.com/LouisBrunner/valgrind-macos/

Apple’s Silicon ARM Architecture CPU (M1, M2, M3):

Requirement:

Introduction:

Start Here (installed Docker Desktop)

1. Write a Dockerfile

# Start image with a node base image of Ubuntu latest verison
FROM ubuntu:latest

# Install necessary package with ubuntu package manager, apt
# Caution: apt install -y parameter is necessary !!!
# To give apt install permission or docker build will fail
RUN apt update && apt install -y make gcc g++ valgrind
  • make – package for Makefile
  • gcc – C/C++ compiler
  • valgrind – C/C++ debugg and test tool

2. Build a docker image with docker build command

docker build -t "valgrind:1.0" .

3. Docker Run to docker container

docker run -it --name valgrind -v $PWD:/tmp -w /tmp valgrind:1.0

Done! Congrats! Enjoy valgrind on your Mac now!

root@containerID:/tmp# 
make -B

Reference:

  1. Valgrind Project, https://valgrind.org/ ↩︎
  2. Makefile force rebuild, https://stackoverflow.com/questions/816370/how-do-you-force-a-makefile-to-rebuild-a-target ↩︎
Allen Cheng Avatar

2 responses to “C/C++ Valgrind MacOS Solution -Docker”

  1. Beauty Fashion Avatar

    Can you write more about it? Your articles are always helpful to me. Thank you!

  2. Hairstyles Avatar

    I do agree with all the ideas you have presented in your post. They’re very convincing and will certainly work. Still, the posts are very short for beginners. Could you please extend them a little from next time? Thanks for the post.