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

  • 相关阅读:
    31. Ubuntu15.04系统中如何启用、禁用客人会话
    dpkg安装deb缺少依赖包的解决方法
    C语言宏中"#"和"##"的用法
    编译android6.0错误recipe for target 'out/host/linux-x86/obj/lib/libart.so' failed
    Android api level对照表
    Android 如何判断CPU是32位还是64位
    vim map nmap(转)
    vim配置及插件安装管理(超级详细)
    Java多线程总结(二)锁、线程池
    Python快速教程目录(转)
  • 原文地址:https://www.cnblogs.com/cutepig/p/1791250.html
Copyright © 2011-2022 走看看