创建 dll 文件
我们如何从现有的 .cpp 文件创建 .dll 文件? 我已经创建了 HelloWorld.cpp 和 HelloWorld.h 文件。
请帮忙。 谢谢。
How can we create a .dll file from an existing .cpp file?
I have my HelloWorld.cpp and HelloWorld.h file already created.
Please help.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这取决于您使用什么编译器(和版本)?我猜是 MSVC++,所以动态库通常是您可以使用的内置模板(可能名为“Win32 DLL”)。 (还有类似的“类库”。)
您的头文件签名可能还应该包含
__declspec(dllexport)
以确保编译器使它们可见。将配置类型更改为“动态库”(在“属性”->“配置属性”->“常规”下)并构建。
请记住:DLL 文件只是普通的旧可执行文件...它们可以包含 Main(),但它们不需要,只是类的集合也完全没问题...您通常甚至可以简单地将 .exe 重命名为.dll,尽管每个编译器都有自己的小东西...
一个有用的链接可能是:http://msdn.microsoft.com/en-us/library/ms235636%28v=vs.80%29.aspx
It depends, what compiler (and version) are you using? I'm guessing MSVC++, so Dynamic Libraries are normally a built-in template (probably named 'Win32 DLL') you can use. (There is also 'Class Library', which is similar.)
Your header file signatures should probably also contain
__declspec(dllexport)
to make sure the compiler makes them visible.Change the configuration type to 'Dynamic Library' (under Properties->Configuration Properties->General) and build.
Remember: DLL files are just normal plain old executables... They can contain a Main(), but they don't need to, just a collection of classes is also perfectly fine... You can often even simply rename .exe to .dll, though every compiler has its own little things...
A useful link might be: http://msdn.microsoft.com/en-us/library/ms235636%28v=vs.80%29.aspx
这取决于平台/编译器。在 Windows 上,使用 Microsoft Visual C++,您会说:
That's platform/compiler dependent. On Windows, with Microsoft Visual C++, you would say: