Valgrind 真是C/C++內存調試的利器


1. 可以下載RPM 包,直接安裝
2. 編譯和安裝Valgrind




(1)從首頁下載, 或者wget http://valgrind.org/downloads/valgrind-3.8.1.tar.bz2, 獲取
(2)解壓bzip2 -d valgrind-3.8.1.tar.bz2
(2) tar -xvf valgrind-3.8.1.tar 進入源代碼目錄 or tar jxvf valgrind-3.***.tar.bz2 直接解壓
(4)運行./configure配置Valgrind,具體參數信息詳見INSTALL文件。一般只需要設置--prefix=/home/you/want/it/installed
(5)make,編譯Valgrind
(6)make install,安裝Valgrind
(7)輸入valgrind --version; 如果有老版本,則需要注意環境變量的設置,保證新安裝的生效。


常見問題:
valgrind: failed to start tool 'memcheck' for platform 'amd64-linux': No such file or directory
一個是版本太低,不支持64bit
二是安裝問題,參考:https://webcache.googleusercontent.com/search?q=cache:6hb5lNVRBDcJ:eatmyrandom.blogspot.com/2010/10/valgrind-and-failed-to-start-tool.html+&cd=1&hl=en&ct=clnk&gl=hk


This is Google's cache of http://eatmyrandom.blogspot.com/2010/10/valgrind-and-failed-to-start-tool.html. It is a snapshot of the page as it appeared on 17 Nov 2012 20:22:04 GMT. The current page could have changed in the meantime. Learn more
Tip: To quickly find your search term on this page, press Ctrl+F or ?-F (Mac) and use the find bar.


Text-only version
 
EatMyRandom Blog




Oct 29, 2010
valgrind and the "failed to start tool 'memcheck'..." error


I've just decided to update valgrind with the latest version and got the following error:
"failed to start tool 'memcheck' for platform 'amd64-linux': No such file or directory"


It looks like the error is pretty much famous. I saw it also on some machines we use at work. I actually desperately needed valgrind, therefore decided to find out what the problem is.


Checking $PATH and $LD_LIBRARY_PATH didn't help - everything was fine. But what really helped is this message, which I should have read before installing valgrind :)


Important!  Do not move the valgrind installation into a place
different from that specified by --prefix at build time.  This will
cause things to break in subtle ways, mostly when Valgrind handles
fork/exec calls
(valgrind's README file)


But you know, I didn't really moved the installation. What I did was just configure and make, but after that I reconfigured it with prefix and didn't issued "make distclean" before reconfiguring :)


So, the recipe is simple. 
If you do "./configure" -- > "make install", than it should be just fine.
But if you do "./configure" -- > "make" -- > "./configure --prefix=..." -- > "make install", than most probably you will get this error message, see the subject.


Well you built valgrind and changed your mind later with the prefix, than don't forget to "make distclean" the source.


Hope it helps and you will not loose hours looking for reasons of the error ;)


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章