5

I have installed valgrind with no problems but when running it I keep getting the following error:

valgrind: failed to start tool 'memcheck' for platform 'amd64-linux': No such file or directory

I have adjusted my bash file accordingly. I added the following path: /usr/bin/valgrind from using: which valgrind command and it's still not working. Then I added the path:/usr/lib/valgrind and it is still not working. I think I am confused about the correct local directory for using Ubuntu.

I am using:

export VALGRIND_LIB="/usr/lib/valgrind"

Do I have to add my local directory first?

Paul Floyd
  • 5,530
  • 5
  • 29
  • 43
Jamie
  • 365
  • 2
  • 5
  • 13

9 Answers9

10

I built valgrind from source and the posted answer did not work for me but this did:

e.g. how i configured:

./configure --prefix=$HOME/local/valgrind

What I added to my ~/.bashrc

export VALGRIND_LIB=$HOME/local/valgrind/libexec/valgrind

Seems like it needed libexec, not lib

ajoseps
  • 1,871
  • 1
  • 16
  • 29
  • This is what worked for me. – Herohtar Oct 18 '21 at 21:11
  • For some reason, when I got 3.16.1 going in my arm/linux environment, /opt/lib/valgrind/ did the trick. Upgrading to 3.20.0, for some reason this error popped up and I had to edit my export to /opt/libexec/valgrind/ – JoeManiaci Dec 14 '22 at 04:04
8

add "export VALGRIND_LIB=/usr/lib/valgrind/"(or /usr/local/lib/valgrind/ or other place where you install your valgrind lib) into ~/.bashrc

Chen Zhang
  • 112
  • 1
  • 2
0

You shouldn't need to set any environment variables, unless you are working on the code of Valgrind itself.

Just run /usr/bin/valgrind. This will then run /usr/lib/valgrind/memcheck-amd64-linux and preload some .so files in the same directory.

I don't have much experience with Debian/Ubuntu, but if you installed it with snap then afaict you should use the --classic option.

Paul Floyd
  • 5,530
  • 5
  • 29
  • 43
  • I have confirmed that this fixes running with `valgrind/3.17.0`. All that it is needed is the $PATH set, not `VALGRIND_LIB`. Setting `VALGRIND_LIB` breaks it. With `valgrind/3.15.0`, the VALGRIND_LIB might be needed. – Mark Lakata Aug 16 '21 at 19:05
0
export VALGRIND_LIB=<where libexec/valgrind is|where massif-arm64-linux is>
ROTOGG
  • 1,106
  • 1
  • 7
  • 17
0

Also make sure you are using a 64bit valgrind for 64 bit executable, using a 32 bit valgrind on a 64 bit exe resuts in this error

/tmp>file /usr/bin/valgrind /usr/bin/valgrind: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, not stripped

/tmp>file a.out a.out: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, not stripped

/tmp>valgrind a.out valgrind: failed to start tool 'memcheck' for platform 'amd64-linux': No such file or directory

siva.p
  • 11
  • 1
0

As the others indicated above, you need export VALGRIND_LIB="path-to-valgrind-lib". If "/usr/lib/valgrind" or "/usr/local/lib/valgrind" does not work, check "/usr/lib/x86_64-linux-gnu/valgrind" too if you are on linux.

0

None of the solutions proposed worked for me, so I enabled all optional modules:

./configure --enable-only64bit --enable-inner --enable-lto --enable-tls

et voila, it worked.

Michał Leon
  • 2,108
  • 1
  • 15
  • 15
0

This error is seen when 32 bit valgrind is used for 64 bit executable. Install 64 bit version of valgrind to resolve the issue.

yum install valgrind.x86_64
GORa
  • 61
  • 6
-1

Try to run using "sudo", in my case it helped.

maxxlife
  • 17
  • 3