将lib文件包装到Dll文件 [英] wrap a lib file to Dll File

查看:101
本文介绍了将lib文件包装到Dll文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我想知道如何将c中的lib文件包装到dll中
文件,以便我可以在c#中使用dll

请帮助

亲切的问候
Saima

Hi all

i wana know how wrap lib file in c into dll
file so that i can use dll in c#

Plz help

KInd Regards
Saima

推荐答案

如果我对您的理解正确,那么您将需要为lib文件中的每个文件编写一个替代入口点,然后根据目标代码创建dll.和现有的lib文件.
因此,例如,对于lib文件中的方法int GetVar(int, char*),您可以将以下内容添加到DLL中:
If I understand you correctly, then you would need to write an alternate entry point for each one in the lib file, then create the dll from your object code and the existing lib file.
So for example for the method int GetVar(int, char*) in the lib file, you would add the following to your DLL:
__declspec(dllexport) int DLLGetVar(int i, char* p)
{
    return GetVar(i, p);
}


然后,您的C#代码将调用DLLGetVar()方法.

如果您有LIB文件的来源,将其转换为DLL会更容易.


Your C# code would then call the DLLGetVar() method.

If you have the source of the LIB file it would be easier just to convert it to a DLL.


这篇关于将lib文件包装到Dll文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆