简体   繁体   English

如何从Visual Studio 2017社区版C ++项目中导出DLL?

[英]How to export a DLL from Visual Studio 2017 Community Edition C++ Project?

I have a Visual Studio 2017 Community Edition. 我有一个Visual Studio 2017社区版。 Started the new C++ console project. 开始新的C ++控制台项目。 Marked the class I want exported as DLL with __declspec(dllexport). 用__declspec(dllexport)标记了我要导出为DLL的类。

But when I build my solution, I only get files with following extensions: .exe, .iobj, .ipdb and .pdb. 但是,在构建解决方案时,我只会获得具有以下扩展名的文件:.exe,.iobj,.ipdb和.pdb。

I tried searching through various settings in Visual Studiom including configuration manager, but I can't find where to enable the option to build the code as DLL. 我尝试搜索包括配置管理器在内的Visual Studiom中的各种设置,但是找不到在哪里启用将代码生成为DLL的选项。 Is it maybe not a part of community edition? 可能不是社区版的一部分吗?

You have to select DLL in Configuration Properties of your project. 您必须在项目的“配置属性”中选择“ DLL”。

Then probably figured out errors, if any 然后可能会找出错误(如果有)


在此处输入图片说明

I have not VS community available right now, but IIRC, in the General project settings, you can select Dynamic Library as the Configuration Type 我现在还没有VS社区,但是在IIRC的“ General项目设置中,您可以选择“ Dynamic Library作为“ Configuration Type

You may also want to set Map Exports and Generate Map File to Yes or something like that, in the linker Debugging settings. 您可能还需要在链接器的“ Debugging设置中将“ Map ExportsGenerate Map File为“ Yes或类似的名称。

You probably will also need a 您可能还需要一个

BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)     
{
    //you should keep hinstDll in a global variable

    //...

    return true;// true means "go on with loading the dll"
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM