Hi, Thanks to Zeman, here is the output of (gcc -v -fmudflap file.cc -lmudflap):
Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/home/user/foss/installed/gcc/libexec/gcc/x86_64-unknown-linux-gnu/4.7.2/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../configure --prefix=/home/user/foss/installed/gcc --enable-languages=c,c++ --disable-multilib --disable-multiarch --enable-checking=runtime --enable-libmudflap --enable-libgomp --disable-bootstrap --enable-static --disable-shared --disable-decimal-float --with-system-zlib --disable-libitm --disable-build-poststage1-with-cxx --disable-build-with-cxx --without-cloog --without-ppl --disable-nls --enable-threads --enable-__cxa_atexit --with-gmp=/home/user/foss/installed/gmp --with-mpfr=/home/user/foss/installed/mpfr --with-mpc=/home/user/foss/installed/mpc Thread model: posix gcc version 4.7.2 (GCC) COLLECT_GCC_OPTIONS='-v' '-fmudflap' '-mtune=generic' '-march=x86-64' /home/user/foss/installed/gcc/libexec/gcc/x86_64-unknown-linux-gnu/4.7.2/cc1plus -quiet -v -D_GNU_SOURCE references.cc -D_MUDFLAP -include mf-runtime.h -quiet -dumpbase references.cc -mtune=generic -march=x86-64 -auxbase references -version -fmudflap -fno-builtin -fno-merge-constants -o /tmp/ccmawnfm.s GNU C++ (GCC) version 4.7.2 (x86_64-unknown-linux-gnu) compiled by GNU C version 4.4.5, GMP version 5.0.5, MPFR version 2.4.2, MPC version 0.8.1 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 ignoring nonexistent directory "/home/user/foss/installed/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../x86_64-unknown-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /home/user/foss/installed/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../include/c++/4.7.2 /home/user/foss/installed/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../include/c++/4.7.2/x86_64-unknown-linux-gnu /home/user/foss/installed/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../include/c++/4.7.2/backward /home/user/foss/installed/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/include /usr/local/include /home/user/foss/installed/gcc/include /home/user/foss/installed/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/include-fixed /usr/include End of search list. GNU C++ (GCC) version 4.7.2 (x86_64-unknown-linux-gnu) compiled by GNU C version 4.4.5, GMP version 5.0.5, MPFR version 2.4.2, MPC version 0.8.1 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 2a2682bf88529e20cb2f41b930a50deb COLLECT_GCC_OPTIONS='-v' '-fmudflap' '-mtune=generic' '-march=x86-64' as -v --64 -o /tmp/ccThOFbp.o /tmp/ccmawnfm.s GNU assembler version 2.20.1 (x86_64-linux-gnu) using BFD version (GNU Binutils for Debian) 2.20.1-system.20100303 COMPILER_PATH=/home/user/foss/installed/gcc/libexec/gcc/x86_64-unknown-linux-gnu/4.7.2/:/home/user/foss/installed/gcc/libexec/gcc/x86_64-unknown-linux-gnu/4.7.2/:/home/user/foss/installed/gcc/libexec/gcc/x86_64-unknown-linux-gnu/:/home/user/foss/installed/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/:/home/user/foss/installed/gcc/lib/gcc/x86_64-unknown-linux-gnu/ LIBRARY_PATH=/home/user/foss/installed/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/:/home/user/foss/installed/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/home/user/foss/installed/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../:/lib/:/usr/lib/ COLLECT_GCC_OPTIONS='-v' '-fmudflap' '-mtune=generic' '-march=x86-64' /home/user/foss/installed/gcc/libexec/gcc/x86_64-unknown-linux-gnu/4.7.2/collect2 --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 /usr/lib/../lib64/crt1.o /usr/lib/../lib64/crti.o /home/user/foss/installed/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/crtbegin.o --wrap=main -L/home/user/foss/installed/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.7.2 -L/home/user/foss/installed/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/home/user/foss/installed/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../.. /tmp/ccThOFbp.o -lmudflap -lstdc++ -lm -export-dynamic -lgcc -lc -lgcc /home/user/foss/installed/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/crtend.o /usr/lib/../lib64/crtn.o /home/user/foss/installed/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib64/libmudflap.a(mf-runtime.o): In function `__mfu_check': /home/user/foss/gcc-4.7.2/build/x86_64-unknown-linux-gnu/libmudflap/../../../libmudflap/mf-runtime.c:912: undefined reference to `__real_malloc' /home/user/foss/gcc-4.7.2/build/x86_64-unknown-linux-gnu/libmudflap/../../../libmudflap/mf-runtime.c:1028: undefined reference to `__real_free' /home/user/foss/installed/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib64/libmudflap.a(mf-runtime.o): In function `__mf_insert_new_object': /home/user/foss/gcc-4.7.2/build/x86_64-unknown-linux-gnu/libmudflap/../../../libmudflap/mf-runtime.c:1074: undefined reference to `__real_calloc' /home/user/foss/installed/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib64/libmudflap.a(mf-runtime.o): In function `__mfu_unregister': /home/user/foss/gcc-4.7.2/build/x86_64-unknown-linux-gnu/libmudflap/../../../libmudflap/mf-runtime.c:1430: undefined reference to `__real_free' /home/user/foss/gcc-4.7.2/build/x86_64-unknown-linux-gnu/libmudflap/../../../libmudflap/mf-runtime.c:1433: undefined reference to `__real_free' /home/user/foss/gcc-4.7.2/build/x86_64-unknown-linux-gnu/libmudflap/../../../libmudflap/mf-runtime.c:1436: undefined reference to `__real_free' PS: Please keep me in CC, I'm not subscribed to the list. Thanks & Regards, Satish On 22 September 2012 08:11, bd satish <bdsat...@gmail.com> wrote: > Hi, > > Here is the output of (gcc -v): > Using built-in specs. > COLLECT_GCC=g++ > COLLECT_LTO_WRAPPER=/home/user/installed/gcc/libexec/gcc/x86_64-unknown-linux-gnu/4.7.2/lto-wrapper > Target: x86_64-unknown-linux-gnu > Configured with: ../configure --prefix=/home/user/installed/gcc > --enable-languages=c,c++ --disable-multilib --disable-multiarch > --enable-checking=runtime --enable-libmudflap --enable-libgomp > --disable-bootstrap --enable-static --disable-shared > --disable-decimal-float --with-system-zlib --disable-libitm > --disable-build-poststage1-with-cxx --disable-build-with-cxx > --without-cloog --without-ppl --disable-nls --enable-threads > --enable-__cxa_atexit --with-gmp=/home/bdsatish/foss/installed/gmp > --with-mpfr=/home/bdsatish/foss/installed/mpfr > --with-mpc=/home/bdsatish/foss/installed/mpc > Thread model: posix > gcc version 4.7.2 (GCC) > > Thanks & Regards, > Satish > > On 22 September 2012 04:33, Frank Ch. Eigler <f...@redhat.com> wrote: >> bd satish <bdsat...@gmail.com> writes: >> >>> [...] >>> The following piece of code, gives "undefined references" to >>> __real_malloc, __real_free, etc.: >>> Compiled with: >>> g++ -fmudflap references.cc -lmudflap >>> >>> /lib64/libmudflap.a(mf-runtime.o): In function `__mfu_check': >>> ../libmudflap/mf-runtime.c:912: undefined reference to `__real_malloc' >>> [...] >> >> According to libmudflap/mf-impl.h, since you're using ordinary >> archives rather than shared libraries (-fPIC) these __real_FOO >> functions are expected to be provided by the linker: >> >> (1) The static method involves a list of -wrap=foo flags being passed to >> the linker, which then links references to "foo" to the symbol >> "__wrap_foo", and links references to "__real_foo" to the symbol "foo". >> When compiled without -DPIC, libmudflap.a contains such __wrap_foo >> functions which delegate to __real_foo functions in libc to get their >> work done. >> >> So, something appears wrong with this wrapping mechanism in your case. >> Can you rerun g++ with -v to see how the linker is invoked? Perhaps >> there is something missing for the C++ static-linking case. >> >> >> - FChE