Click here to Skip to main content
15,893,487 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all,
I have a c++ dll and a .net core console application which invokes the c++ library and works fine in windows platform. But now I need to do the same in linux platform. Please help how to invoke the dll in .net core to run in linux platform.

Thanks

What I have tried:

[DllImport(@"C:\..\lib\DLLDemo.dll", EntryPoint = "math_add", CallingConvention = CallingConvention.StdCall)]
       public static extern int Add(int a, int b);
       [DllImport("user32.dll")]
       public static extern int MessageBox(IntPtr hWnd, String text, String caption, int options);
       public static void Main(string[] args)
       {
           int result = Add(14, 54);
           Console.WriteLine("result is {0}", result);
           Console.ReadKey();
       }
Posted
Comments
Richard MacCutchan 24-May-17 3:59am    
The same way you did it in Windows. But you need to rebuild the DLL on Linux.
User1454 24-May-17 4:19am    
Hi thanks. Is it by publishing for linux platform by setting in program.csproj?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900