11 messages in net.java.dev.jna.usersRe: [jna-users] NativeLibrary Usage
FromSent OnAttachments
Christine GrudeckiJul 26, 2007 7:11 am 
Timothy WallJul 26, 2007 8:35 am 
Christine GrudeckiJul 26, 2007 12:52 pm 
Timothy WallJul 26, 2007 1:21 pm 
pzab...@poczta.onet.plJul 27, 2007 8:57 am 
Timothy WallJul 27, 2007 11:24 am 
Timothy WallJul 30, 2007 3:41 am 
Timothy WallJul 30, 2007 7:54 am 
Timothy WallJul 30, 2007 8:58 am 
Christine GrudeckiJul 30, 2007 9:24 am 
Timothy WallJul 30, 2007 10:49 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [jna-users] NativeLibrary UsageActions...
From:Timothy Wall (twal@dev.java.net)
Date:Jul 30, 2007 3:41:18 am
List:net.java.dev.jna.users

On Jul 30, 2007, at 4:55 AM, pzab@poczta.onet.pl wrote:

I changed for a while the abstract class into interface in order to check if this is the reason of the problem.

Well, it won't work at all with an abstract class, that's for sure.

I also included the full path to my cpp dll. I exported static functions for it (in order to avoid any problems connected to decorated export from exported classes).

The exported methods must be declared 'extern "C"' if you're compiling the code as C++. There is a FunctionMapper in JNA to handle __stdcall-decorated names (e.g. _MyFunction@8) if you haven't remapped the symbols to be undecorated.

So, now I have:

package jnatest;

import com.sun.jna.Library;

import com.sun.jna.Native;

public interface testJNADllInterface extends Library {

testJNADllInterface INSTANCE =

(testJNADllInterface)Native.loadLibrary ("D:/MyPath/ CPPDynamicLibToBeCalledViaJNA.dll", testJNADllInterface.class);

int SetValue(int i);

}

and I am using this interface this way:

testJNADllInterface lib = testJNADllInterface.INSTANCE;

lib.SetValue(1);

for(int i=0;i<5;i++){

lib.SetValue(i);

}

The Eclipse PlugIn hungs on:

testJNADllInterface lib = testJNADllInterface.INSTANCE;

If you attach to the process with Visual Studio, what do you see the program doing? Do you have a DllMain (you don't necessarily need one)? Does your library have static initializers? Can you call LoadLibrary on it from a simple C program?