You are not logged in.

#1 2007-10-16 09:11:54

NecroRomancist
Member
Registered: 2005-01-02
Posts: 53

Java Native Access

I'm trying to get jna working for a project of mine but i get an unsatisfied link error and i really don't know why :S
I'm using jna to load a shared lib i did to access the cdrom drive. Basically what i did was:

- Got a static build of libcdio and libiso9660
- Implemented in C what i needed
- Created a shared lib with that implementation and linked it against libcdio.a and libiso9660.a

The makefile (ignore the make clean clause smile )

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

all:  iso cd

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

iso: iso.o
    $(CC) -shared -Wl,-soname,jIso.so.1 -o "jIso.so.1.0.1"  iso.o -L .  -liso9660 

cd: cd.o
    $(CC) -shared -Wl,-soname,jCdio.so.1 -o "jCdio.so.1.0.1"  cd.o -L .  -lcdio

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

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

The jna interface

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 way i'm calling the libs

        System.setProperty("jna.lib.path","/home/persefone/Esoteric/jar/native/linux/");
        
        iso9660Lib INSTANCE = (iso9660Lib)Native.loadLibrary("jIso", iso9660Lib.class);
        
        iso9660Lib iso = INSTANCE;
        
        iso.iso_init(args[0]);

Any ideas ?

This really got me stuck sad

Last edited by NecroRomancist (2007-10-16 09:12:44)

Offline

#2 2007-10-20 01:12:42

NecroRomancist
Member
Registered: 2005-01-02
Posts: 53

Re: Java Native Access

Well it wasn't a problem with JNA, i was linking the static lib in a wrong way, i linked against the shared one and it worked smile
Can someone please tell me how to to wrap a static lib over a dynamic one? man ld wasn't that helpful sad

Offline

#3 2007-11-12 01:17:36

Kknd
Member
From: Brazil, Santa Catarina
Registered: 2007-08-15
Posts: 100
Website

Re: Java Native Access

A static lib isn't just a bunch of objects together? You can extract them from the .a and link it when you're creating the dynamic library.

Offline

Board footer

Powered by FluxBB