在 Visual Studio 2010 C++ 中使用 .dll
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7136450/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Using .dll in Visual Studio 2010 C++
提问by sdasdadas
I have a problem. I place my .DLL and .LIB file in the same directory as my project, go to Properties -> Common Properties -> Framework and References -> Add New Reference. But the list comes up empty.
我有个问题。我将我的 .DLL 和 .LIB 文件放在与我的项目相同的目录中,转到 Properties -> Common Properties -> Framework and References -> Add New Reference。但是这个列表是空的。
Is there something else I should be doing?
还有什么我应该做的吗?
回答by Nicol Bolas
C++ is not C#. You don't include .dlls in C++ applications by adding "references". Unless it's C++/CLI, but that's not C++.
C++ 不是 C#。您不会通过添加“引用”在 C++ 应用程序中包含 .dll。除非它是 C++/CLI,但那不是 C++。
In C++, you would go, in the project configuration, to Linker->Input->Additional Dependencies. There, you would list the library name plus path to the .lib in question.
在 C++ 中,您将在项目配置中转到 Linker->Input->Additional Dependencies。在那里,您将列出库名称以及相关 .lib 的路径。
Normally, when you build a Windows C/C++ DLL, you also get a .lib. This is an import library; users of the library include (as stated above) that .lib in order to access the DLL. They generally do not load the .dll directly (though there are ways to do that).
通常,当您构建 Windows C/C++ DLL 时,您还会获得一个 .lib。这是一个导入库;库的用户包括(如上所述)该 .lib 以便访问 DLL。他们通常不直接加载 .dll(尽管有办法做到这一点)。