how to compile ruby with gprof


./configure debugflags=”-pg -g” # note — might need to for sure not –enable-shared


edit Makefile, add -pg to LDFLAGS, possibly to the lines around it, too


make install

6 thoughts on “how to compile ruby with gprof”

  1. on mingw by default you’ll get

    sh-3.1$ make
    gcc -shared -Wl,–enable-auto-image-base,–enable-auto-import -Wl,–out-implib=libmsvcrt-ruby191.dll.a msvcrt-ruby191.def dln.o encoding.o prelude.o array.o bignum.o class.o compar.o complex.o dir.o enum.o enumerator.o error.o eval.o load.o proc.o file.o gc.o hash.o inits.o io.o marshal.o math.o numeric.o object.o pack.o parse.o process.o random.o range.o rational.o re.o regcomp.o regenc.o regerror.o regexec.o regparse.o regsyntax.o ruby.o safe.o signal.o sprintf.o st.o strftime.o string.o struct.o time.o transcode.o util.o variable.o version.o compile.o debug.o iseq.o vm.o vm_dump.o thread.o cont.o ascii.o us_ascii.o unicode.o utf_8.o newline.o langinfo.o fileblocks.o crypt.o lgamma_r.o strlcpy.o strlcat.o win32.o dmyext.o msvcrt-ruby191.res.o -lshell32 -lws2_32 -o msvcrt-ruby191.dll
    Creating library file: libmsvcrt-ruby191.dll.a
    dln.o: In function `fprintf’:
    C:/installs/build_env/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/stdio.h:243: undefined reference to `mcount’
    dln.o: In function `sprintf’:
    C:/installs/build_env/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/stdio.h:263: undefined reference to `mcount’
    dln.o: In function `dln_load’:
    C:/dev/ruby/downloads/ruby_trunk/dln.c:1206: undefined reference to `mcount’
    dln.o: In function `dln_find_1′:
    C:/dev/ruby/downloads/ruby_trunk/dln.c:1521: undefined reference to `mcount’
    dln.o: In function `dln_find_file_r’:
    C:/dev/ruby/downloads/ruby_trunk/dln.c:1499: undefined reference to `mcount’
    dln.o:C:/dev/ruby/downloads/ruby_trunk/dln.c:1514: more undefined references to `mcount’ follow
    collect2: ld returned 1 exit status
    make: *** [msvcrt-ruby191.dll] Error 1

    which means “you need to link with -pg, too!” (LDFLAGS and all its siblings, within Makefile)

  2. gcc -shared -o .ext/i386-mingw32/enc/ enc/encdb.o -L. -L. -L. -Wl,–enable-auto-image-base,–enable-auto-import -lmsvcrt-ruby191 -lshell32 -lws2_32
    enc/encdb.o: In function `Init_encdb’:
    C:/dev/ruby/downloads/ruby_trunk/./enc/encdb.c:23: undefined reference to `mcount’
    collect2: ld returned 1 exit status
    make[1]: *** [.ext/i386-mingw32/enc/] Error 1

    meant “add -pg next to -lws2_32 in”

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.