I am using Linux64-bit for the test program and have two libraries (*.so)
files.
libxyz.so
libabc.so
For header files I have created XyzAPI and AbcAPI interfaces and mapped the
C functions to Java methods. All simple implementations work fine.
But places where XYZ function implementation which calls one of the ABC
function I receive the following exception:
/usr/java/jdk1.5.0_12/bin/java: symbol lookup error:
/home/kunal/workspace/jna/lib/native/linux/libxyz.so: undefined symbol:
CreateEvent
Also, the same thing happens where XYZ function implementation which calls
one of the other default library function: (I believe this is a call to
/usr/lib64/librt.so)
/usr/java/jdk1.5.0_12/bin/java: symbol lookup error:
/home/kunal/workspace/jna/lib/native/linux/libxyz.so: undefined symbol:
clock_gettime
How do I tell JNA that libxyz.so is dependent upon "libabc.so" as well as
"librt.so"?
Here's the code (not the exact as I have) but copying some to give idea:
libxyz.so contains:
extern "C" int openConnection(const char *pHostName, HANDLE
notificationEvent)
{
printf("inside openconnection\n");
if (notificationEvent == NULL)
{
printf("open connection temp event = null\n");
return -222;
}
CreateEvent(NULL, TRUE, FALSE, NULL);
return 100;
}
libabc.so contains:
HANDLE CreateEvent(LPVOID lpSA ,
BOOL bManualReset ,
BOOL bInitiallyOwn ,
LPCSTR lpName );
java impl:
static AbcAPI INSTANCE = AbcAPI.class.cast(Native.loadLibrary("abc",
AbcAPI.class));
public class CheckConnection {
public static void main(String args[]) {
System.setProperty("java.library.path","/usr/lib:/home/kunal/workspace/jna/lib/native/linux");
XyzAPI xyzapi = XyzAPI.INSTANCE;
AbcAPI abcapi = AbcAPI.INSTANCE;
xyzapi.initialize();
Pointer notifyEvent = abcapi.createNotificationEvent();
xyzapi.openConnection("localhost", notifyEvent);
Thanks,
Kunal