Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run valgrind with basic c example?

Tags:

Installation:

bzip2 -d valgrind-3.10.1.tar.bz2 tar -xf valgrind-3.10.1.tar  

then:

./configure make make install 

or simplier

sudo apt-get install valgrind 

How to run valgrind on that simple program example1.c

#include <stdlib.h> int main() {     char *x = malloc(100); /* or, in C++, "char *x = new char[100] */     return 0; } 

Run:

valgrind --tool=memcheck --leak-check=yes example1 valgrind: example1: command not found 

Output from console:

valgrind: example1: command not found 
like image 766
andrew Avatar asked Mar 28 '15 23:03

andrew


1 Answers

It looks good. You only need to add a ./ before your executable. Without it, valgrind fails to find it and reports 'command not found'.

valgrind --tool=memcheck --leak-check=yes ./example1                                           ^ 
like image 70
swalog Avatar answered Nov 01 '22 04:11

swalog