如何产生一个只有资源没有DllMain()的DLL

 

如何产生一个只有资源没有DllMain()的DLL


用VC产生一个DLL,加入rc文件,删掉.c和.h文件,加入rc文件对应的resource.h头文件

1、新建工程Win32 Dynamic-Link Library,一个空的工程,选择相应的生成路径和工程名字。

2、添加   ****.rc 和 resource.h的头文件,进行修改操作。

3、添加编译设置Configurations。 步骤:Build -> Configurations->Add。 若添加UDebug,则

      在Copy Setting from 选择 Debug;URelease 同理 Release。

4、分别设置UDebug 和URelease 的属性设置。 Project->Setting->C/C++->Catrgory

      Preprocessor ,在Preprocessor definitions 中添加 _UNICODE,UNICODE

     其中,URelease中添加NDEBUG,UDebug是_DEBUG

5、有时还要替换掉原有文件中包含过去resource.h。比如stdafx.h 等。

编译,连接错误:

LINK : error LNK2001: unresolved external symbol __DllMainCRTStartup@12

查MSDN文章:DLL for Beginners. 如果一个DLL没有DllMain()--(当然这个DllEntry可以在VC的编译选项里指定,或者/DllEntry:FuncName。),编译器自动使用C Runtime Library的DllMainCRTStartup().

加入msvcrt.libmsvcrtd.lib (for debug mode),编译通过。这个DLL没有显式的DllMain().

注意:

有时会报错误 cmd.exe 无法运行。

则是 Project->Setting->post-build step 的路径设置错误

UDebug的情况下:

copy .\UDebug\pollmodifierres.dll    ..\..\..\public\binv4\URelease

URelease的情况下:

copy .\URelease\pollmodifierres.dll    ..\..\..\public\binv4\URelease

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The KB article is apply to the previous version of VC, in visual studio 2005, there is a little different on how to set the configurations. but the principle under the configuration is the same.

To solve it, do the following steps:

1.    Open project property pages by Alt+F7

2.    Navigate to Configuration properties->Linker->Input section.

3.    Add msvcrtd.lib; mfcs80ud.lib to the Ignore specific library.

4.    Add mfcs80ud.lib msvcrtd.lib to the Additional dependencies.

Now we will tell you how to find out these two disorder libraries. In the project property pages, navigate to configuration properties->linker->command line, add /verbose:lib to the additional option. Rebuild your project, and look carefully to the output window, you will find that is mfcs80ud.lib generated the link error, look before mfcs80ud.lib, you will find there is only one CRT library before it, so ignore these 2 libraries in the Ignore specific library, then add them in the additional dependencies with right order. Rebuild again, it should works.


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值