C++ 在使用make制作的文件上使用Valgrind
我试图在一个程序上使用valgrind,该程序是使用以下makefile的make命令的输出:C++ 在使用make制作的文件上使用Valgrind,c++,linux,makefile,valgrind,C++,Linux,Makefile,Valgrind,我试图在一个程序上使用valgrind,该程序是使用以下makefile的make命令的输出: # Intlist makefile P = intlist C = g++ F = -m32 -g -O0 -Wall O = IntListTest.o IntList.o $(P): $(O) $(C) $(F) -o $(P) $(O) IntListTest.o: IntListTest.cpp IntList.h $(C) $(F) -c IntListTest.cp
# Intlist makefile
P = intlist
C = g++
F = -m32 -g -O0 -Wall
O = IntListTest.o IntList.o
$(P): $(O)
$(C) $(F) -o $(P) $(O)
IntListTest.o: IntListTest.cpp IntList.h
$(C) $(F) -c IntListTest.cpp
IntList.o: IntList.cpp IntList.h
$(C) $(F) -c IntList.cpp
clean:
rm $(P) $(O)
当我在intlist上运行valgrind时,它会生成以下内容:
==130929== Memcheck, a memory error detector
==130929== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==130929== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==130929== Command: intlist
==130929==
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: strlen
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
valgrind:
valgrind: Possible fixes: (1, short term): install glibc's debuginfo
valgrind: package on this machine. (2, longer term): ask the packagers
valgrind: for your Linux distribution to please in future ship a non-
valgrind: stripped ld.so (or whatever the dynamic linker .so is called)
valgrind: that exports the above-named function using the standard
valgrind: calling conventions for this platform. The package you need
valgrind: to install for fix (1) is called
valgrind:
valgrind: On Debian, Ubuntu: libc6-dbg
valgrind: On SuSE, openSuSE, Fedora, RHEL: glibc-debuginfo
valgrind:
valgrind: Note that if you are debugging a 32 bit process on a
valgrind: 64 bit system, you will need a corresponding 32 bit debuginfo
valgrind: package (e.g. libc6-dbg:i386).
valgrind:
valgrind: Cannot continue -- exiting now. Sorry.
我觉得我的makefile有点问题,但我不确定它是什么。非常感谢您的任何想法。但是,这发生在一个学院拥有的服务器上,我没有安装任何东西的权限,因此这不是我的解决方案。您正在构建一个32位可执行文件(编译/链接行中的
-m32
选项),但是来自valgrind提供的输出,您没有在32位可执行文件上运行valgrind的所有支持库
你真的需要32位的程序吗?如果不是,最简单的方法就是删除-m32
选项,然后清理并重建所有内容
如果您确实需要32位二进制文件,请仔细阅读上面valgrind提供的输出,以确定您缺少哪些额外的32位库,需要安装。稍不相关的注释。make已经为您所做的大部分工作提供了“标准”变量。CXX为C++编译器CXXFLAGS,用于C++编译器标志。如果您希望其他人阅读您的makefile,我建议您使用这些。