loadNativeLibrary static method

DynamicLibrary loadNativeLibrary()

Implementation

static DynamicLibrary loadNativeLibrary() {
  // Support LD_LIBRARY_PATH
  String libraryPath = Platform.environment["OKAPI_LIBRARY_PATH"] ??
      path.join(Directory.current.path, '..', 'libs');
  String libraryName = "";
  if (Platform.isWindows) {
    libraryName = path.join("windows", "okapi.dll");
  } else if (Platform.isLinux) {
    libraryName = path.join("linux", "libokapi.so");
  } else if (Platform.isMacOS) {
    libraryName = path.join("macos", "libokapi.dylib");
  } else if (Platform.isAndroid) {
    libraryPath = "";
    libraryName = "libokapi.so";
  } else if (Platform.isIOS) {
    // iOS has everything compiled in.
    return DynamicLibrary.process();
  }
  libraryPath = path.join(libraryPath, libraryName);
  final nativeLib = DynamicLibrary.open(libraryPath);
  return nativeLib;
}