Jump to content
Excelsior Forums
Akos

creating .lib files

Recommended Posts

I've created a dll containing everything I need for running my java routines (jetperfect).

How can I create a lib file to link to my executable (load time dynamic linking) ?

If I call my dll "jvm.dll", and link with jdk's jvm.lib, then it seems to work, but I'd like a propper solution instead of hacking...

Share this post


Link to post
Share on other sites

Hello.

As I understood, you want to get the import library in the format that MS link may take as input.

Currently, it is impossible to do with JET, because it uses its own object (and library) file formats.

But I may suggest you a method of creating of such libraries using MS Visual C.

Suggest the name of dll is MyDLL.dll and %jdk_home% environment variable is properly set.

1. Create MyDLL.def with the following contents:

EXPORTS

       JNI_GetDefaultJavaVMInitArgs

       JNI_CreateJavaVM

       JNI_GetCreatedJavaVMs

2.  Create MyDLL.c with the following contents:

#define _JNI_IMPLEMENTATION_

#include "jni.h"

_JNI_IMPORT_OR_EXPORT_ jint JNICALL

JNI_GetDefaultJavaVMInitArgs(void *args){

   return 0;

}

_JNI_IMPORT_OR_EXPORT_ jint JNICALL

JNI_CreateJavaVM(JavaVM **pvm, void **penv, void *args){

   return 0;

}

_JNI_IMPORT_OR_EXPORT_ jint JNICALL

JNI_GetCreatedJavaVMs(JavaVM **VMs, jsize len, jsize *nVMs){

   return 0;

}

3. Run

cl /LD MyDLL.c /I%jdk_home%\include /I%jdk_home%\include\win32 /FeMyDLL.dll -link /def:MyDLL.def /implib:MyDLL.lib

So the MyDLL.lib is produced as output. (MyDLL.dll that is also produced is a "fake" dll that contains empty implementations).

I hope it will help.

-AlexM

Share this post


Link to post
Share on other sites

×