zoukankan      html  css  js  c++  java
  • MFC Link problem

    nafxcw.lib    for MFC Static  Link Library

    Use of MFC in a Shared  DLL : _AFXDLL  in "preprocessor definitions" list defined

    When Using both CRT and MFC libraries together you need to be careful. In such cases its important for MFC libraries to get linked before CRT libraries.

    If you are using MFC, you need to link libc.lib before msvcrt.lib. You can do this by explicitely setting linker option.

    please go through this link... http://support.microsoft.com/kb/148652
    problem while linking CRT and MFC together

    Great!!! Thanks alot sach!!

    The solution I used was as per the link and creating a new header file, ForceLib.h. The file looks like this:
    Code:
    #ifndef _AFX_NOFORCE_LIBS

    /////////////////////////////////////////////////////////////////////////////
    // Win32 libraries

    #ifndef _AFXDLL
        #ifndef _UNICODE
            #ifdef _DEBUG
                #pragma comment(lib, "nafxcwd.lib")
            #else
                #pragma comment(lib, "nafxcw.lib")
            #endif
        #else
            #ifdef _DEBUG
                #pragma comment(lib, "uafxcwd.lib")
            #else
                #pragma comment(lib, "uafxcw.lib")
            #endif
        #endif
    #else
        #ifndef _UNICODE
            #ifdef _DEBUG
                #pragma comment(lib, "mfc71d.lib")
                #pragma comment(lib, "mfcs71d.lib")
            #else
                #pragma comment(lib, "mfc71.lib")
                #pragma comment(lib, "mfcs71.lib")
            #endif
        #else
            #ifdef _DEBUG
                #pragma comment(lib, "mfc71ud.lib")
                #pragma comment(lib, "mfcs71ud.lib")
            #else
                #pragma comment(lib, "mfc71u.lib")
                #pragma comment(lib, "mfcs71u.lib")
            #endif
        #endif
    #endif

    #ifdef _DLL
        #if !defined(_AFX_NO_DEBUG_CRT) && defined(_DEBUG)
            #pragma comment(lib, "msvcrtd.lib")
        #else
            #pragma comment(lib, "msvcrt.lib")
        #endif
    #else
    #ifdef _MT
        #if !defined(_AFX_NO_DEBUG_CRT) && defined(_DEBUG)
            #pragma comment(lib, "libcmtd.lib")
        #else
            #pragma comment(lib, "libcmt.lib")
        #endif
    #else
        #if !defined(_AFX_NO_DEBUG_CRT) && defined(_DEBUG)
            #pragma comment(lib, "libcd.lib")
        #else
            #pragma comment(lib, "libc.lib")
        #endif
    #endif
    #endif

    #pragma comment(lib, "kernel32.lib")
    #pragma comment(lib, "user32.lib")
    #pragma comment(lib, "gdi32.lib")
    #pragma comment(lib, "msimg32.lib")
    #pragma comment(lib, "comdlg32.lib")
    #pragma comment(lib, "winspool.lib")
    #pragma comment(lib, "advapi32.lib")
    #pragma comment(lib, "shell32.lib")
    #pragma comment(lib, "comctl32.lib")
    #pragma comment(lib, "shlwapi.lib")

    // force inclusion of NOLIB.OBJ for /disallowlib directives
    #pragma comment(linker, "/include:__afxForceEXCLUDE")

    // force inclusion of DLLMODUL.OBJ for _USRDLL
    #ifdef _USRDLL
    #pragma comment(linker, "/include:__afxForceUSRDLL")
    #endif

    // force inclusion of STDAFX.OBJ for precompiled types
    #ifdef _AFXDLL
    #pragma comment(linker, "/include:__afxForceSTDAFX")
    #endif

    #endif //!_AFX_NOFORCE_LIBS

  • 相关阅读:
    怎样启用或关闭Windows的Telnet功能
    打开SQL Server 配置管理器时出现了问题 ,无法连接到WMI提供程序,您没有权限或者该服务器无法访问
    服务器迁移注意什么?
    测试技能进阶图谱
    Mac
    Maven
    .net发送邮箱
    MongoDB 未添加索引 当数据量较大时 分页查询报错问题解决
    代码保存
    这技术网站不错
  • 原文地址:https://www.cnblogs.com/cutepig/p/1791250.html
Copyright © 2011-2022 走看看