+ /* Statically load the library which contains all native functions used in here */
+ static private boolean isNativeInited = false;
+ public static void nativeInit() {
+ if (isNativeInited)
+ return;
+
+ if (System.getProperty("os.name").toLowerCase().startsWith("win"))
+ NativeLib.nativeInit("winpthread-1");
+
+ NativeLib.nativeInit("simgrid");
+ NativeLib.nativeInit("simgrid-java");
+ isNativeInited = true;
+ }
+
+ public static void nativeInit(String name) {
+ try {
+ /* Prefer the version of the library bundled into the jar file and use it */
+ loadLib(name);
+ } catch (SimGridLibNotFoundException embeededException) {
+ /* If not found, try to see if we can find a version on disk */
+ try {
+ System.loadLibrary(name);
+ } catch (UnsatisfiedLinkError systemException) {
+ if (! name.equals("boost_context")) { // Ignore when we cannot load boost_context
+
+ System.err.println("\nCannot load the bindings to the "+name+" library in path "+getPath());
+ Throwable cause = embeededException.getCause();
+ if (cause instanceof java.lang.UnsatisfiedLinkError && cause.getMessage().matches(".*libcgraph.so.*"))
+ System.err.println("HINT: Try to install the libcgraph package (sudo apt-get install libcgraph).");
+ else
+ System.err.println("This jar file does not seem to fit your system, and no usable SimGrid installation found on disk.");
+ System.err.println();
+ cause.printStackTrace();
+ System.exit(1);
+ }
+ }
+ }
+ }