10

I'm installing valgrind now, until the ‘make install’ command it goes good. The next command- ‘make regtest’ outputs the next error:

../../depcomp: line 689: exec: g++: not found
make[5]: *** [leak_cpp_interior.o] Error 127
make[5]: Leaving directory `/home/kbubuntu/valgrind-3.9.0/memcheck/tests'
make[4]: *** [check-am] Error 2
make[4]: Leaving directory `/home/kbubuntu/valgrind-3.9.0/memcheck/tests'
make[3]: *** [check-recursive] Error 1
make[3]: Leaving directory `/home/kbubuntu/valgrind-3.9.0/memcheck/tests'
make[2]: *** [check-recursive] Error 1
make[2]: Leaving directory `/home/kbubuntu/valgrind-3.9.0/memcheck'
make[1]: *** [check-recursive] Error 1
make[1]: Leaving directory `/home/kbubuntu/valgrind-3.9.0'
make: *** [check] Error 2

How can I solve it?

Thanks.

Daniel Griscom
  • 1,834
  • 2
  • 26
  • 50
Shtrudle
  • 105
  • 1
  • 2
  • 8

4 Answers4

47

Short answer: Make from source.

How?

  1. Uninstall the non working valgrind version with root rights (eg. sudo):

apt-get --purge valgrind or dpkg --remove valgrind or yum remove valgrind

  1. Obtain sources from here.

  2. Identify the latest version (for example 3.17.0)

  3. Download sources : wget https://sourceware.org/pub/valgrind/valgrind-3.17.0.tar.bz2

  4. Decompress archive tar xvf valgrind-3.17.0.tar.bz2

  5. Go to uncompressed archive cd valgrind-3.17.0

  6. Configure ./configure

  7. Compile make

  8. Install make install (with root rights, eg. sudo)

Note: very useful for Raspberry Pi 4 users - Default valgrind installation generate a lot of internal errors. See Valgrind reports hundreds of errors in Hello World program on RaspberryPi 4B

AmateurDAero
  • 103
  • 1
g10guang
  • 4,647
  • 3
  • 28
  • 22
  • 3
    For Dockerfile: # Valgrind! # RUN apt-get install -y valgrind ADD https://sourceware.org/pub/valgrind/valgrind-3.15.0.tar.bz2 /tmp/valgrind-3.15.0.tar.bz2 WORKDIR /src RUN tar --strip-components=1 -x -f /tmp/valgrind-3.15.0.tar.bz2 \ && cd build \ && ../configure \ --prefix=/opt/valgrind \ && make \ && make install \ && rm -f /tmp/valgrind-3.15.0.tar.bz2 ENV VALGRIND_LIB /opt/valgrind/lib/valgrind ENV PATH="/opt/valgrind/bin:${PATH}" – Thomas J Younsi Aug 17 '19 at 00:39
17

All major linux distributions will include valgrind in their repositories. You can find this on debian derived, apt based systems with:

apt search valgrind

But first just try:

apt install valgrind

It should work, and pull in any dependencies. Remember, if you are not the superuser, you'll need to preface those with sudo.

It's a great tool, have fun.

CodeClown42
  • 11,194
  • 1
  • 32
  • 67
  • sir i just did it.. and it worked.. kindly tell me whose cache server it is using.. – shiv garg Jul 24 '14 at 14:19
  • You mean `apt`? That depends on your exact distro and how it is configured. It's a separate question to this one though ;) If you have an answer to your original question, tick one of the checkmarks to indicate this. – CodeClown42 Jul 24 '14 at 14:22
  • 1
    If you want to ask about `apt`, the Unix & Linux Exchange is a more appropriate place: http://unix.stackexchange.com/questions – CodeClown42 Jul 24 '14 at 14:23
2

i think its due to dependency not met. install g++ by

sudo apt-get install g++

then try again. error is due to exec is unable to find any package named g++

shiv garg
  • 761
  • 1
  • 8
  • 26
0

When trying to install Valgrind in Ubuntu 20.04, you can use apt or snap (notice the version number):

:~/valgrind-3.18.1$ valgrind

Command 'valgrind' not found, but can be installed with:

sudo snap install valgrind # version 3.18.1, or sudo apt install valgrind # version 1:3.15.0-1ubuntu9.1

Although snap provides the latest version, I preferred to install it natively by compiling the source code following the @g10guang instructions.

Bruce_Warrior
  • 1,161
  • 2
  • 14
  • 24