1 Reply Latest reply: Mar 13, 2009 2:22 AM by 843810 RSS

    compiling mtrace under cygwin

    843810
      Hi,
      I had a tough time figuring out how to compile mtrace in a cygwin environment, so I thought I'd post what I did to help others.

      First, use the gcc from mingw (mingw.org), not the standard gcc that comes with cygwin. After downloading and installing mingw, just put the mingw/bin directory first in your PATH.

      Here's the script I used. Obviously you could use a Makefile - the main point is that this set of options works. Without the -D_JNI_IMPLEMENTATION_ option, you'll get a "Could not find Agent_OnLoad function in the agent library: mtrace" error. The paths are Windows-style paths (e.g. "c:/"). And the mtrace.dll does need to be put in your JRE/bin directory.

      JDK=c:/dev/jdk1.5
      INCLUDE=$JDK/include

      for i in mtrace.c agent_util.c java_crw_demo.c
      do
      gcc -D_JNI_IMPLEMENTATION_ -g -fno-strict-aliasing -fno-omit-frame-pointer -W -Wall -Wno-unused -Wno-parentheses -I. -I$INCLUDE -I$INCLUDE/win32 -shared -c$i
      done

      gcc -D_JNI_IMPLEMENTATION_ -Wl,--kill-at -shared -g -fno-strict-aliasing -fno-omit-frame-pointer -W -Wall -Wno-unused -Wno-parentheses -I. -I$INCLUDE -I$INCLUDE/win32 -Wl,-soname=mtrace.dll -static-libgcc -mimpure-text -o mtrace.dll mtrace.o agent_util.o java_crw_demo.o -L $JDK/jre/lib

      cp mtrace.dll $JDK/jre/bin
        • 1. Re: compiling mtrace under cygwin
          843810
          Thanks for the post.

          I am compiling my source code with -D_JNI_IMPLEMENTATION_ but still getting the error.

          Error occurred during initialization of VM
          Could not find Agent_OnLoad function in the agent library: C:\libJVM_TIDemo.dll.

          Do you have any idea abt this issue.


          Thanks in advance
          Regards
          Ronkio