Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

JVM_DumpAllStacks/cl linking

Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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
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.

Posts: 67682
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Please do not cross-post the same question in multiple forums. It wastes people's time when multiple redundant conversations take place.
Look ma! I'm selling my stuff!
the value of filler advertising in 2021
    Bookmark Topic Watch Topic
  • New Topic