前面写的是废话:最近用C++写数据库系统,内存泄露很严重,想要安装内存检测工具valgrind,但是这东西对我的MAC OS X 10.6不太支持,加上一些另外的原因,我决定在MAC下安个Ubuntu。。。。什么,问我安Valgrind的流程?我刚安好Ubuntu,Valgrind还没搞定呢,跟我在mac下安装的问题一样。。。一会在说吧:P (后续:Valgrind安装流程在本文最后)
在MAC OS X下用VMware安装Ubuntu流程:
1.下载安装Vmware Fusion。上官网下载也行,我从太平洋上下的 http://dl.pconline.com.cn/download/61935.html,然后又在百度知道上搜了3.0的序列号:YU2NJ-JVGKY-44N8R-H8Q5Y-0PGE3
安装很简单,一步步来就行了。
Valgrind安装流程
1. 继续上官网http://valgrind.org/downloads/current.html,下完了解压。
2.用命令行进入到解压完的文件夹下,然后输入./configure命令,再然后是make命令,make check命令,最后是make install命令。如果make install不能用,尤其是认真看出错的输出是文件夹建立失败,应该是你没有root权限。输入su root登陆权限,然后再次输入make install就好了~
3.完毕~
4.另外,如果用Valgrind运行程序时出现如下错误:
valgrind: Fatal error at startup: a function redirection
valgrind: which is mandatory for this platform-tool combination
valgrind: cannot be set up. Details of the redirection are:
valgrind:
valgrind: A must-be-redirected function
valgrind: whose name matches the pattern: index
valgrind: in an object with soname matching: ld-linux.so.2
valgrind: was not found whilst processing
valgrind: symbols from the object with soname: ld-linux.so.2
就安装一下Ubuntu的ibc6-dbg包就解决了,在命令行里执行sudo apt-get install libc6-dbg
这个错误是因为为了避免该工具出错,执行时会调用strlen检查,所以一开始不能找到这个函数的话,valgrind就拒绝继续执行。