6 messages in net.java.dev.jna.usersRe: [jna-users] JNA / Linux problem -...
FromSent OnAttachments
Benjamin BOUCHERAug 13, 2008 10:36 am 
Benjamin BOUCHERAug 13, 2008 11:19 am 
Timothy WallAug 13, 2008 11:44 am 
Benjamin BOUCHERAug 14, 2008 1:03 am 
Timothy WallAug 14, 2008 3:58 am 
Benjamin BOUCHERAug 14, 2008 4:42 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] JNA / Linux problem - Error looking up functionActions...
From:Timothy Wall (twal@dev.java.net)
Date:Aug 13, 2008 11:44:39 am
List:net.java.dev.jna.users

StdCallLibrary is only for windows dlls that use the stdcall calling convention. One way to define a single interface that works on both linux and windows follows:

public interface MyLibrary implements Library { interface MyLibraryW32 extends MyLibrary implements StdCallLibrary { } MyLibrary INSTANCE = (MyLibrary)Native.loadLibrary("myLibrary", Platform.isWindows() ? MyLibraryW32.class : MyLibrary.class); }

Use "nm" or some other symbol dumper to see what symbols are actually defined in your library.

It's also possible that your C header is defining macros which convert the function names into a different symbol.

On Aug 13, 2008, at 1:36 PM, Benjamin BOUCHER wrote:

Hi,

I am currently working on a project using a C library through JNA, it works fine under Windows, but not under linux. When I try to call a function from my JNA lib , I get the following error message :

Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: Error looking up function 'NexusInitialize': /usr/lib/libnexusSDK.so: undefined symbol: NexusInitialize

I get the same result with all functions, yet I am sure that those functions are in the .so because I can use its in C.

My interface declaration :

public interface LibNexus extends StdCallLibrary {

LibNexus INSTANCE = (LibNexus) Native.loadLibrary("nexusSDK", LibNexus.class); LibNexus SYNC_INSTANCE = (LibNexus) Native.synchronizedLibrary(INSTANCE);

short NexusInitialize();

I tried with

public interface LibNexus extends Library

but got the same result.

Need help :>