12 messages in net.java.dev.jna.usersRe: [jna-users] Example not running o...
FromSent OnAttachments
Steve RamageMay 13, 2008 4:24 pm 
Timothy WallMay 13, 2008 5:05 pm 
Steve RamageMay 14, 2008 10:28 am 
Steve RamageMay 14, 2008 10:36 am 
Timothy WallMay 14, 2008 10:47 am 
Timothy WallMay 14, 2008 10:56 am 
Steve RamageMay 14, 2008 11:35 am 
Timothy WallMay 14, 2008 12:00 pm 
Steve RamageMay 14, 2008 1:51 pm 
Steve RamageMay 14, 2008 3:53 pm 
Steve RamageMay 14, 2008 6:03 pm 
Timothy WallMay 19, 2008 7:43 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] Example not running on Solaris 9 x86.Actions...
From:Timothy Wall (twal@dev.java.net)
Date:May 13, 2008 5:05:33 pm
List:net.java.dev.jna.users

Solaris 9 doesn't have glibc installed, which is what libjnidispatch.so (extracted as a temporary file) is linked against.

Someone else had run into this before; I suppose the solution would be to build against whatever the "standard" libc is for solaris by some combination of flags to gcc (although I don't think gcc is included on solaris 9, so that in itself might pose a problem).

Alternatively, maybe there's just something JNA is referring to that's in glibc but not in the other libc.so. You could start by simply attempting a build of JNA on the solaris 9 machine and see what happens.

On May 13, 2008, at 7:24 PM, Steve Ramage wrote:

I have the simple example program: package com.sun.jna.examples;

import com.sun.jna.Library; import com.sun.jna.Native; import com.sun.jna.Platform;

/** Simple example of native library declaration and usage. */ public class HelloWorld {

public interface CLibrary extends Library { CLibrary INSTANCE = (CLibrary) Native.loadLibrary((Platform.isWindows() ? "msvcrt" : "c"), CLibrary.class);

void printf(String format, Object... args); }

public static void main(String[] args) { //System.loadLibrary("c"); CLibrary.INSTANCE.printf("Hello, World\n"); for (int i=0;i < args.length;i++) { CLibrary.INSTANCE.printf("Argument %d: %s\n", i, args[i]); } } }

Trying to run, when I try to run it I get:

java -Djna.library.path="/usr/lib" -cp jna.jar:. com.sun.jna.examples.HelloWorld

It works on another machine no problem, both using Java 5.

Looking at the truss output I see:

/1: xstat(2, "/var/tmp/jna14055.tmp", 0x080454CC) = 0 /1: xstat(2, "/usr/jdk1.5.0_15/jre/lib/i386/client/libc.so.1", 0x08045430) Err#2 ENOENT /1: xstat(2, "/usr/jdk1.5.0_15/jre/lib/i386/libc.so.1", 0x08045430) Err#2 ENOENT Exception in thread "main" java.lang.UnsatisfiedLinkError: /var/tmp/ jna14055.tmp: ld.so.1: java: fatal: libc.so.1: open failed: No such file or directory at java.lang.ClassLoader$NativeLibrary.load(Native Method) at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1751) at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1647) at java.lang.Runtime.load0(Runtime.java:769) at java.lang.System.load(System.java:968) at com.sun.jna.Native.loadNativeLibrary(Native.java:509) at com.sun.jna.Native.<clinit>(Native.java:91) at com.sun.jna.examples.HelloWorld $CLibrary.<clinit>(HelloWorld.java:11) at com.sun.jna.examples.HelloWorld.main(HelloWorld.java:20)

My class path is set to:

declare -x LD_LIBRARY_PATH="/usr/lib"

Finally I can call System.load(‘c’); without any problems.