Search code examples
pinvokewrapperdumpbin

Get functions from lib


First my knowledge of C++ is limited, as well I'm new to pinvoke.

I've got a library with some very old code in it, that we want to use with C# but of course being old it's in unmanged C++. I am looking to make a C# dll wrapper for the lib. so in future anyone who wants to use the code can just use the dll. However I can find how to export the function to do a pinvoke. I tried dumpbin but didn't see any. Or do I just need to get the functions from the code? Below is the dumpbin.

enter image description here


Solution

  • What you need to do depends on what sort of library it is.

    1. If it is a static library then you'll need to build a DLL and link the .lib file to that DLL. Then your C# code can p/invoke to the DLL you built.
    2. If it is an import library for a DLL, then you just p/invoke straight to the DLL. The .lib file is no use to you here.