I installed valgrind on Snow Leopard using the patch at https://bugs.kde.org/show%5Fbug.cgi?id=205241 . However, when I run it with a binary I compiled from C++ code, I'm told that valgrind "cannot execute binary file". What g++ flags should I set to make my program work with valgrind?
+2
A:
Be sure to use the -m32 option to generate a 32-bit executable. The compiler default is 64-bit (assuming you have a 64-bit machine), but valgrind does not yet officially support 64-bit executables on Mac OS X. The file
command on your executable should report "Mach-O executable i386".
mark4o
2009-10-27 00:51:05
Thanks! This is just what I was looking for. However, I couldn't get it to compile. I'm using a makefile to do all this, and after adding the -m32 option, I'm told that "file is not of required architecture" for all of my .o files.
weicool
2009-10-28 21:19:57
You need -m32 for both compiling and linking; it sounds like you may have added it for compiling only. Also be sure that you have 32-bit versions of all the libraries you are using.
mark4o
2009-10-29 06:56:49