When you want to use native libraries from C# you won't need a .lib file. The way this is handled in .NET is by using Platform Invoke (P/Invoke). I suggest you follow the tutorial on MSDN, it will get you started:
If you want to generate a wrapper you might want to have a look at the P/Invoke Interop Assistant on CodePlex. Please note that this tool works on the original C/C++ code. Using a .dll file to create a wrapper is not feasible because native DLLs don't store the signature of the exported functions (as described in this thread) and a lib file will store the signature in a compiler specific way.
发布评论
评论(1)
当您想要使用 C# 中的本机库时,您不需要 .lib 文件。在 .NET 中处理此问题的方法是使用平台调用 (P/Invoke)。我建议您按照 MSDN 上的教程进行操作,它将帮助您入门:
如果您想要生成一个包装器,您可能需要查看P/Invoke Interop Assistant 在 CodePlex 上。请注意,该工具适用于原始 C/C++ 代码。使用 .dll 文件创建包装器是不可行的,因为本机 DLL 不存储导出函数的签名(如 此线程)和 lib 文件将以编译器特定的方式存储签名。
When you want to use native libraries from C# you won't need a .lib file. The way this is handled in .NET is by using Platform Invoke (P/Invoke). I suggest you follow the tutorial on MSDN, it will get you started:
If you want to generate a wrapper you might want to have a look at the P/Invoke Interop Assistant on CodePlex. Please note that this tool works on the original C/C++ code. Using a .dll file to create a wrapper is not feasible because native DLLs don't store the signature of the exported functions (as described in this thread) and a lib file will store the signature in a compiler specific way.