用gcc(C编译器)编译C++程序,会报标题的错误。

  原因是用gcc编译c++程序时,链接的库文件为libstdc++.so,而不是默认的libc.so,因此需要用-lstdc++参数指明,否则会在链接时发生错误.

如:  gcc -g helloworld.cpp -lstdc++

  ①下载安装  valgrind-3.15.0.tar,解压后安装

$ cd valgrind-3.15.0
$ ./autogen.sh
$ ./configure
$ make
$ sudo make install

  ②使用

g++ -g -o test testValgrind.c
valgrind --tool=memcheck --leak-check=full ./test
原文地址:https://www.cnblogs.com/mathyk/p/12213517.html