在C ++中使用动态库 [英] Using Dynamic Libraries in C++

查看:142
本文介绍了在C ++中使用动态库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

经过几年的C#编程,几个月前,我重新开始使用C ++进行编码.在C#中,使用Microsoft Visual C#,我将创建dll,然后在程序中使用这些dll.我要做的就是导入,然后通过gui添加引用.我尝试在C ++中执行类似的操作,但无法使其正常工作.我创建了一个dll项目,然后当我尝试在C ++中使用dll时说找不到类.我希望我能清楚地知道我想做什么.

另一个可能对我有所帮助的问题.假设我要使用iostream. iostream是在dll中正确吗?我想做类似的事情.

Hello,

I restarted coding in C++ a couple of months ago, after several years of C# programming. And in C#, Using Microsoft Visual C#, I would create dlls and then use the dlls in my programs. All I would have to do is import of course and add the reference through the gui. I tried doing something similar in C++, but I can''t get it to work. I create a dll project and then when I try to use the dll in C++ it says class not found. I hope I''m giving a clear view of what I would like to do.

Another question that might help me or might not. Let''s say that I want to use iostream. iostream is in a dll correct? I want to do something like that.

推荐答案

您可以使用静态或动态链接.对于VS2005,您可以在此处
You can use static or dynamic linking. For VS2005 you can find samples here and here
I would recommend dynamic linking.

If you need to use libraries which you don''t own, you''ll need the .lib file along with the .DLL. You must specify the additional libs in project''s properties->Configuration properties->Linker->Input->Additional Dependencies. Of course, you must ensure the compiler can find them. If they are not in PATH, then you can specify where to search: Configuration properties->Linker->General->Additional Library Directories

Iostream is part of standard libraries, you don''t need to include anything.


这篇关于在C ++中使用动态库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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