Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JVM_DumpAllStacks/cl linking

James Leith
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks,
I am trying to create a piece of JNI code( as a dll ) where the
native function invokes JVM_DumpAllStacks which exists
in jvm.lib distributes 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
Microsoft (R) Incremental Linker Version 7.10.3077
Copyright (C) Microsoft Corporation. All rights reserved.

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 SRC_DIR=.

set INCLUDES=-I. -I%JDK_HOME%\include -I%JDK_HOME%\include\win32 -I %SRC_DIR%

set NAME=ThreadDumpUtility

rem cl /c /Zi %INCLUDES% ThreadDumpUtility.c

rem link /dll /out:ThreadDumpUtility.dll ThreadDumpUtility.obj %JDK_HOME%\lib\jvm.lib

cl %INCLUDES% /Zd /MD /LD ThreadDumpUtility.c -FeThreadDumpUtility.dll -link %JDK_HOME%\lib\jvm.lib

My .c file is as follows:

#include <stdio.h>
#include <jni.h>

#include "ThreadDumpUtility.h"

JNIEXPORT void JNICALL Java_ThreadDumpUtility_generateThreadDump(JNIEnv *env, jobject obj)
JVM_DumpAllStacks( env, NULL );

//printf("Generating Thread Dump....\n");

OS is Windows XP SP2

If anyone can help point out my mistakes I would be most grateful.

  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic