Forums › General Discussions › dotnet Core and Linux › Reply To: dotnet Core and Linux
August 20, 2019 at 12:57 pm #229024
Participant
Upon further investigation, you can change the sm_api.cs to just be like:
[DllImport("sm_api", CallingConvention = CallingConvention.Cdecl)]
public static extern SmStatus smGetDeviceList(int[] serials, ref int deviceCount);
[DllImport("sm_api", CallingConvention = CallingConvention.Cdecl)]Then if you’re on Linux, it looks for sm_api.so, libsm_api.so and on windows it looks for sm_api.dll
Nice little benefit for interoperability. If you need to specify x64, x64 and other arch’s, you’ll probably need to SetDllDirectory or LoadLibrary with a dynamically added name, or a custom build step to rename the proper dll and put it with the assembly. DllImport only can do so much matching.