Hi folks, I am trying to create( as a dll) a piece of JNI code where the native function invokes JVM_DumpAllStacks which exists in jvm.lib distributed in Weblogic 8.1. The code works fine with the call to JVM_DumpAllStacks commented out and a simple printf() call, but when I try to compile with JVM_DumpAllStacks uncommented I get a linkage problem as follows:
C:\AAA\JamesTDU>cl -I. -Ic:\bea\jdk142_05\include -Ic:\bea\jdk142_05\include\win32 -I . /Zd /MD /LD ThreadDumpUtility.c -FeThreadDumpUtility.dll -link c:\bea\jdk142_05\lib\jvm.lib ThreadDumpUtility.c Microsoft (R) Incremental Linker Version 7.10.3077 Copyright (C) Microsoft Corporation. All rights reserved.
/debug /dll /implib:ThreadDumpUtility.lib /out:ThreadDumpUtility.dll c:\bea\jdk142_05\lib\jvm.lib ThreadDumpUtility.obj Creating library ThreadDumpUtility.lib and object ThreadDumpUtility.exp ThreadDumpUtility.obj : error LNK2019: unresolved external symbol _JVM_DumpAllStacks referenced in function _Java_ThreadDumpUtility_generateThreadDump@8 ThreadDumpUtility.dll : fatal error LNK1120: 1 unresolved externals
I assume this is because either (a) I haven't linked jvm.lib correctly or (b) Weblogic 8.1 doesn't have JVM_DumpAllStacks in jvm.lib any more. I suspect (a) as I am not very experienced in building dll's using cl.
My build script is as follows:
set JDK_HOME=c:\bea\jdk142_05 set PATH=%JDK_HOME%\lib;C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin;C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\ide;%PATH%
set INCLUDES=-I. -I%JDK_HOME%\include -I%JDK_HOME%\include\win32 -I %SRC_DIR%
rem cl /c /Zi %INCLUDES% ThreadDumpUtility.c
rem link /dll /out:ThreadDumpUtility.dll ThreadDumpUtility.obj %JDK_HOME%\lib\jvm.lib