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

Posted on 2020-01-19 14:23  yacbo  阅读(236)  评论(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

博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3