这个这个dll的编译过程中,为了用到MFC的类,我在StdAfx.h文件中
注释掉了#include <windows.h>,加上mfc的一些头文件,如下//#include <windows.h>
#include <afxwin.h>         // MFC core and standard components
#include <afxext.h>         // MFC extensions
#include <afxdisp.h>        // MFC Automation classes
#include <afxdtctl.h> // MFC support for Internet Explorer 但是编译过程中出现如下问题,不知道怎么办,烦了好几天了,高手们请帮忙
Linking...
Nafxcwd.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in VnetMenu.obj
Nafxcwd.lib(dllmodul.obj) : warning LNK4006: _DllMain@12 already defined in VnetMenu.obj; second definition ignored
   Creating library Debug/VnetMenu.lib and object Debug/VnetMenu.exp
Debug/VnetMenu.dll : fatal error LNK1169: one or more multiply defined symbols found为了它,头发都掉了很多了。

解决方案 »

  1.   

    Solution One: Force Linker to Link Libraries in Correct Order
    Open the Project Settings dialog box by clicking Settings on the Build menu. 
    In the Settings For view, click to select (highlight) the project configuration that is getting the link errors. 
    Click the Link tab. 
    Click to select INPUT in the Category combo box. 
    In the Libraries to Ignore edit box, insert the library names (for example, Nafxcwd.lib Libcmtd.lib). NOTE: The linker command-line equivalent in /NOD:<library name>. 
    In the Object/library Modules edit box, insert the library names. You must ensure that these are listed in order and as the first two libraries in the line (for example, Nafxcwd.lib Libcmtd.lib). 
    Solution Two: Locate and Correct the Problem Module
    Perform the following steps to view the current library link order: 
    Open the Project Settings dialog box by clicking Settings on the Build menu. 
    In the Settings For view, click to select (highlight) the project configuration that is getting the link errors. 
    Click the Link tab. 
    Type the following in the Project Options dialog box:
    /verbose:lib
    Rebuild your project. The libraries will be listed in the output window during the linking process.
    MSDN:
    PRB: LNK2005 Errors When Link C Run-Time Libraries Are Linked Before MFC Libraries Q148652
      

  2.   

    DllMain重定义    ~C Run Time库和MFC库冲突了~
      

  3.   

    Alt +F7 C/C++选项卡 Code Generation选择 Use Run-time Library 这里面的选项要一致
      

  4.   

    To:gracezhu(eutom) ,这个文章我也查到了,可是已经做了,行不通阿!!!!
    To:laiyiling(最熟悉的陌生人) ,不清楚,可能是dll跟mfc里面的冲突,但不知道怎么解决!!
      

  5.   

    To:laiyiling(最熟悉的陌生人) ,如何才能一致,我就是编译一个单线程的DLL而已,该选择哪个呢?????????
      

  6.   

    你还是建立一个 MFC DLL 吧
      

  7.   

    不太清楚应该怎么做阿,麻烦laiyiling(最熟悉的陌生人)详细说说。谢谢
      

  8.   

    重新做一个dll的话,很大工作量阿,麻烦帮帮忙,我已经搞了好多天了。没有多少时间了。
      

  9.   

    Alt +F7 C/C++选项卡Code Generation选择Use Run-time Library这里面的选项在Use Run-time Library下面的下拉列表里的设置要和你的程序一致,实在不知道你就把里面的几个都试一下。
      

  10.   

    To:laiyiling(最熟悉的陌生人),个个选项都试完了,已经试了好几次了,都不行阿,希望可以继续提供帮助。
    网上也也有出现类似的问题,但是没有相应的解决方法,惨。
      

  11.   

    MFC里面本身已经包含了DllMain。
    你的Dll里面也有DllMain~
    如果你的DllMain里没有做什么工作,就扔掉它
      

  12.   

    To:rivershan(笨猫)(深入浅出DLL与Hook) 去掉了向导生成的DLLMain,可以成功编译,非常感谢。BOOL APIENTRY DllMain( HANDLE hModule, 
                           DWORD  ul_reason_for_call, 
                           LPVOID lpReserved
     )
    {
        switch (ul_reason_for_call)
    {
    case DLL_PROCESS_ATTACH:
    case DLL_THREAD_ATTACH:
    case DLL_THREAD_DETACH:
    case DLL_PROCESS_DETACH:
    break;
        }
        return TRUE;
    }但请问一下,去掉向导的DLLMian,编译出来出来的dll在让其他程序调用的时候,应该没有问题吧??
      

  13.   

    没问题
    DllMain主要是做一些初始化的工作,你不初始化就没影响,在你的情况下,它默认调用的应该是MFC库的DllMain