Got it running all ok while in B4J compiled though when I produce the EXE file (using Launch4J) and try to execute it seems that it does not find the required dll file. The program does not crash or such but it just does not perform the related actions to dll calls.
The dll is placed in Files folder in B4J program and when compiling the library the dll is in /libs folder. Library compiled with SLC v1.1
In library src I use:
@BA.Hide
public interface libA extends Library {
// create a run-time link to the DLL
libA INSTANCE = (libA) Native.loadLibrary("libA", libA.class);
...
...
}
I do have tried to place the dll in the EXE folder to no joy.
I have read around and seen this:
static { System.load(anywheresoftware.b4a.objects.streams.File.getDirApp() + "/libA.dll"); }
but I have no knowledge on how to modify the library source.
This is the library source:
package LibA;
import anywheresoftware.b4a.BA.Author;
import anywheresoftware.b4a.BA.ShortName;
import anywheresoftware.b4a.BA.Version;
import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.BA.DependsOn;
import com.sun.jna.Library;
import com.sun.jna.Memory;
import com.sun.jna.Native;
import com.sun.jna.ptr.IntByReference;
@Version(1.0f)
@Author("test")
@ShortName("LibA")
@DependsOn(values={"jna-4.3.0","jna-platform-4.3.0"})
public class LibA {
//static { System.load(anywheresoftware.b4a.objects.streams.File.getDirApp() + "/libA.dll"); }
public char DeviceIndex ;
@BA.Hide
public interface libA extends Library {
// create a run-time link to the DLL
libAs INSTANCE = (libA) Native.loadLibrary("libA", libA.class);
// method prototypes
public short AConnectDevice(char DeviceIndex);
}
public short ConnectALP()
{
char devIndex = 0;
short result;
result = libA.INSTANCE.AConnectDevice(devIndex);
return result;
}
}