5 messages in net.java.dev.jna.usersproblems with jna - cdrom control lib
FromSent OnAttachments
Rui CaridadeOct 17, 2007 2:45 pm 
Timothy WallOct 17, 2007 4:12 pm 
Glick, Gene (GE Indust, Security)Oct 19, 2007 9:45 am 
Timothy WallOct 19, 2007 11:35 am 
Rui CaridadeOct 23, 2007 9:21 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:problems with jna - cdrom control libActions...
From:Rui Caridade (waih@yahoo.com)
Date:Oct 17, 2007 2:45:00 pm
List:net.java.dev.jna.users

Hi all. I'm using jna to access a couple of libs i did to get some info the cdrom and iso images. My lib uses a static build of libcdio which i wrap over a *.so lib (it seem easier than do the whole bindings for libcdio :)

The cdrom interface

int cd_init(char * sDevice); int cd_get_lba(); int cd_get_mode(); int cd_read_sector(char * target, int secstart, int secnum); int load_from_cd(char * fname,unsigned char * mempos); int cd_close();

// iso interface

int iso_init(char * sDevice); int iso_read_sector(char * target, int secstart, int secnum); int load_from_iso(char * fname,unsigned char * mempos); int iso_close();

// how i'm build the libs

INCLUDES = -I /usr/include/ OBJS = cd.o iso.o CC = gcc CFLAGS = -fPIC

all: iso cd

clean: rm -f $(OBJS) "jIso.so.1.0.1" "jCdio.so.1.0.1" *.*~*

iso: iso.o $(CC) -shared -Wl,--export-dynamic,-soname,jIso.so.1 -o "libjIso.so" iso.o -liso9660

cd: cd.o $(CC) -shared -Wl,--export-dynamic,-soname,jCdio.so.1 -o "libjCdio.so" cd.o -lcdio

iso.o: iso.c $(CC) -c $(CFLAGS) $(INCLUDES) iso.c

cd.o: cd.c $(CC) -c $(CFLAGS) $(INCLUDES) cd.c

The java interface (cdio is basically the same)

package io.libJia;

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

public interface iso9660Lib extends Library {

int iso_init(String sDevice);

int iso_close();

int iso_read_sector(Pointer p, int secstart, int secnum);

int load_from_iso(String fname ,Pointer mempos);

}

// The test

NativeLibrary.addSearchPath("libjIso.so","/home/persefone/Esoteric/jar/native/linux/");

iso9660Lib iso = (iso9660Lib)NativeLibrary.getInstance("libjIso.so");

if(iso == null) System.out.println("Ooops");

iso.iso_init(args[0]);

// the result

Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'libjIso.so' at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:100) at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:139) at test.main(test.java:14)

I'm running this from within eclipse.The jar is on the classpath but not on the same dir as the libs i'm calling can that be the reason.This is the first time i'm trying to use jna so please feel free to point my stupid mistakes..

All the best