/* * internal delegate void MyCrossplatformBar(int a, int b); * * * DllLoadUtils dllLoadUtils = IsLinux() ? (DllLoadUtils) new DllLoadUtilsLinux() * : new DllLoadUtilsWindows(); * string libraryName; * * if (IsLinux()) { * libraryName = IntPtr.Size == 8 ? "mylib64.so" : "mylib32.so"; * } else { * libraryName = IntPtr.Size == 8 ? "mylib64.dll" : "mylib32.dll"; * } * * var dllHandle = dllLoadUtils.LoadLibrary(libraryName); * var functionHandle = dllLoadUtils.GetProcAddress(dllHandle, "MyCrossplatformBar"); * * var method = (MyCrossplatformBar) Marshal.GetDelegateForFunctionPointer( * functionHandle, typeof (MyCrossplatformBar)); * method(10, 15); * } * */ public static bool LoadLibrary(string name) { DllLoadUtils dllLoadUtils = null; switch (RunningPlatform()) { case PlatformID.MacOSX: dllLoadUtils = (DllLoadUtils) new DllLoadUtilsMac(); break; case PlatformID.Unix: dllLoadUtils = (DllLoadUtils) new DllLoadUtilsUnix(); break; default: dllLoadUtils = (DllLoadUtils) new DllLoadUtilsWindows(); break; } IntPtr dllHandle; dllHandle = dllLoadUtils.LoadLibrary(name); if (dllHandle == IntPtr.Zero) { Console.WriteLine("Unable to load dll {0}", name); return(false); } ArikaRaw.ResolveSymbols(dllLoadUtils, dllHandle); return(true); }
public static void Main(string[] args) { string libraryName = "t2-output/macosx-clang-debug-default/libarika-qt.dylib"; if (!ArikaLoader.LoadLibrary(libraryName)) { Console.WriteLine("Unable to load dll: {0}", libraryName); return; } ArikaRaw.WindowCreateMain(); for (;;) { if (ArikaRaw.Update() == 0) { break; } } Console.WriteLine("Hello World!"); }