You are not logged in.
Pages: 1
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 )
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
Last edited by NecroRomancist (2007-10-16 09:12:44)
Offline
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
Can someone please tell me how to to wrap a static lib over a dynamic one? man ld wasn't that helpful
Offline
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
Pages: 1