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 ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

JVM_DumpAllStacks/cl linking

 
Greenhorn
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
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 CLASSPATH=C:\AAA\JamesTDU

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.

Thanks,
James.
 
Sheriff
Posts: 67665
173
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.
 
Don't destroy the earth! That's where I keep all my stuff! Including this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic