views:

937

answers:

1

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
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
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