Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • Post Reply 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

JVM_DumpAllStacks/cl linking

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
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.
 
Because those who mind don't matter and those who matter don't mind - Seuss. Tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic