I have an API which is comprised of a header (.h) and the library (.a) files.
I’ve never touched C and i need to access this API from C# and interact with it’s functions.
Most questions regarding this topic say i need to do something like [DllImport("insert_the_dll_name_here")] this to invoke the DLL methods. But i only have the .h and .a files.
What should i do?
Should i compile these files into the DLL and then use pInvoke? If so, How?
Or should i write a wrapper class? If so how?
Any help is appreciated.
If your
.afiles contain Windows-format object files, then you can extract the archive (use the cygwinartool for that) and link those into a C++/CLI project. C++/CLI can use your header files, call C functions directly, and create .NET classes which C# can use just as easily as any Microsoft-provided library class.If your
.afiles contain Linux-format object files, you’ll need to go back to whoever provided them and ask the code to be recompiled for Windows.