3 messages in net.java.dev.jna.users[jna-users] Using multiple libraries
FromSent OnAttachments
Felipe Armoni, felipe.armoniMay 20, 2009 7:32 am 
Jorge NtoMay 20, 2009 8:11 am 
Timothy WallMay 20, 2009 11:55 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:[jna-users] Using multiple librariesActions...
From:Felipe Armoni, felipe.armoni (farm@itautec.com)
Date:May 20, 2009 7:32:43 am
List:net.java.dev.jna.users

Hi,

I am developing a managed .dll in Visual C++ that has several other dlls as its
dependencies. After I compiled it, I created a lib folder in my Java Eclipse
project and put my dll and all the other dependencies inside it.

My first problem is that whenever I have to access my dll I need to provide the
full system path, I cannot just write its name. Therefore the statement below
works: public Lumidigm INSTANCE = (Lumidigm) Native.loadLibrary("C:\\Itautec\\Central
Biometrica\\Java\\LumidigmSensor\\lib\\Lumidigm\\LumidigmHelper.dll",
Lumidigm.class);

But this other statement throws the following exception: public Lumidigm INSTANCE = (Lumidigm) Native.loadLibrary("LumidigmHelper.dll",
Lumidigm.class);

Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load
library '\lib\Lumidigm\LumidigmHelper.dll': Não foi possível encontrar o módulo
especificado.

at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:145)

at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:188)

at com.sun.jna.Library$Handler.<init>(Library.java:123)

at com.sun.jna.Native.loadLibrary(Native.java:255)

at com.sun.jna.Native.loadLibrary(Native.java:241)

at
br.com.itautec.centralbiometrica.nativeInterfaces.lumidigm.Lumidigm.<clinit>(Lumidigm.java:12)

at br.com.itautec.innovatricsEngine.Program.main(Program.java:34)

The dll's path is <project folder>\lib\Lumidigm. Do I have to include this path
on the classpath for this to work? If so how can I do that with Eclipse?

My second problem is that I am trying to put some logging inside my dll and I am
using the log4net api to do it. The thing is that I keep getting the error
below:

# # An unexpected error has been detected by Java Runtime Environment: # # Internal Error (0xe0434f4d), pid=3772, tid=468 # # Java VM: Java HotSpot(TM) Client VM (1.6.0_02-b06 mixed mode, sharing) # Problematic frame: # C [kernel32.dll+0x12a5b] # # An error report file with more information is saved as hs_err_pid3772.log # # If you would like to submit a bug report, please visit: # http://java.sun.com/webapps/bugreport/crash.jsp #

I think that this is because the dll is not finding the log4net.xml or the
log4net.dll, but I am not sure. I have tested this dll with another C++ program
and it worked fine, plus all the required dlls and xmls are in the same folder
as my dll.

Do any of you have a recommendation as what I should do? Does anyone uses
logging in their dlls? Should I continue to use log4net or do you recommend
another api?

I also thought about making all of my functions return a char* with the logging
information, this way I could log everything in the java program using log4j,
although this seems like a rather dirty solution to me...

Thank you all, Felipe