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

Posted on 2020-01-19 14:23  yacbo  阅读(222)  评论(0编辑  收藏  举报

  原因是用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

Copyright © 2024 yacbo
Powered by .NET 8.0 on Kubernetes