使用在Visual Studio℃的DLL ++ [英] Using a DLL in Visual Studio C++

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

问题描述

我有我一直在使用与Visual C#没有问题的(简单地将基准,并使用该命名空间)的DLL。现在,我想学C ++,我不明白你是如何从一个DLL引用命名空间。在一个项目中,我可以右击并选择引用,并从那里点击添加新的参考,但只是为我提供了一个空的项目窗口中。我缺少什么?

I have a DLL that I've been using with no problem in Visual C# (simply adding the reference and using the namespace). Now I'm trying to learn C++, and I don't understand how you reference a namespace from a DLL. I can right-click on a project and select 'references' and from there click 'add new reference', but that just provides me with an empty 'projects' window. What am I missing?

推荐答案

C ++是一种许多从C不同#/ VB.Net时谈到处理DLL引用。在C#是做一个参考所需的所有是一个DLL,因为它包含了描述奠定里面的结构的元数据。编译器可以读取该信息,使得它们可以从另一项目中使用。

C++ is a lot different from C#/VB.Net when it comes to processing DLL references. In C# all that is needed to do a reference is a DLL because it contains metadata describing the structures that lay inside. The compiler can read this information such that they can be used from another project.

C ++不具有元数据的在这个意义上,C#的确该DLL的概念。相反,你必须明确提供一个头文件的形式的元数据。这些文件包含在你的C ++项目,然后DLL是在运行时加载延迟。你实际上并没有添加引用,所以在C ++说话,但包含一个头文件来代替。

C++ does not have the concept of metadata in the DLL in the sense that C# does. Instead you must explicitly provide the metadata in the form of a header file. These files are included in your C++ project and then the DLL is delay loaded at runtime. You don't actually "add a reference" so to speak in C++ but include a header file instead.

在头文件被包含,则可以将其加入你的CPP文件访问该命名空间

Once the header file is included, you can then access the namespace by including it in your CPP files

using namespace SomeNamespace;

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

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