Linking...
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
Debug/hello.exe : fatal error LNK1120: 2 unresolved externals
我是创建一个空白的win32项目工程里面加入了《深入浅出mfc》里p173的hello例子文件然后编译连接出现这样的错误的!在cmd环境下用书上的hello.mak编译连接则没有问题!是要将编译参数中的/MLd修改为/Md吗?但是每次修改后没有效果,它自动还原为/MLd!

解决方案 »

  1.   

    这是我编译时的参数:
    /nologo /MLd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Fp"Debug/hello.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /Md /GZ /c
      

  2.   

    如果用到了mfc就要选use mfc in a share dllALT+F7,General里面
      

  3.   

    如果手动改编译参数(显示在面板里的)可能不行,要用上面的界面操作来修改lib有加入工程吗
      

  4.   

    /MD, /ML, /MT, /LD   (Use Run-Time Library)
    Home |  Overview |  How Do I |  Compiler OptionsWith these options, you can select either single-threaded or multithreaded run-time routines, indicate that a multithreaded module is a dynamic-link library (DLL), and select the retail or debug version of the library.Note   Having more than one copy of the run-time libraries in a process can cause problems, because static data in one copy is not shared with the other copy. To ensure that your process contains only one copy, avoid mixing static and dynamic versions of the run-time libraries. The linker will prevent you from linking with both static and dynamic versions within one .EXE file, but you can still end up with two (or more) copies of the run-time libraries. For example, a dynamic-link library linked with the static (non-DLL) versions of the run-time libraries can cause problems when used with an .EXE file that was linked with the dynamic (DLL) version of the run-time libraries. (You should also avoid mixing the debug and non-debug versions of the libraries in one process.)Command Line Project Settings Description 
    /MD Multithreaded DLL Defines _MT and _DLL so that both multithread- and DLL-specific versions of the run-time routines are selected from the standard .H files. This option also causes the compiler to place the library name MSVCRT.LIB into the .OBJ file. 
    Applications compiled with this option are statically linked to MSVCRT.LIB. This library provides a layer of code that allows the linker to resolve external references. The actual working code is contained in MSVCRT.DLL, which must be available at run time to applications linked with MSVCRT.LIB. 
    /MDd Debug Multithreaded DLL  Defines _DEBUG, _MT, and _DLL so that debug multithread- and DLL-specific versions of the run-time routines are selected from the standard .H files. It also causes the compiler to place the library name MSVCRTD.LIB into the .OBJ file.  
    /ML Single-Threaded  Causes the compiler to place the library name LIBC.LIB into the .OBJ file so that the linker will use LIBC.LIB to resolve external symbols. This is the compiler’s default action. LIBC.LIB does not provide multithread support.  
    /MLd Debug Single-Threaded  Defines _DEBUG and causes the compiler to place the library name LIBCD.LIB into the .OBJ file so that the linker will use LIBCD.LIB to resolve external symbols. LIBCD.LIB does not provide multithread support.  
    /MT Multithreaded  Defines _MT so that multithread-specific versions of the run-time routines are selected from the standard header (.H) files. This option also causes the compiler to place the library name LIBCMT.LIB into the .OBJ file so that the linker will use LIBCMT.LIB to resolve external symbols. Either /MT or /MD (or their debug equivalents /MTd or /MDd) is required to create multithreaded programs.  
    /MTd Debug Multithreaded  Defines _DEBUG and _MT. Defining _MT causes multithread-specific versions of the run-time routines to be selected from the standard .H files. This option also causes the compiler to place the library name LIBCMTD.LIB into the .OBJ file so that the linker will use LIBCMTD.LIB to resolve external symbols. Either /MTd or /MDd (or their non-debug equivalents /MT or MD) is required to create multithreaded programs.  
    /LD Not applicable Creates a DLL. 
    Passes the /DLL option to the linker. The linker looks for, but does not require, a DllMain function. If you do not write a DllMain function, the linker inserts a DllMain function that returns TRUE. 
    Links the DLL startup code.
    Creates an import library (.LIB), if an export (.EXP) file is not specified on the command line; you link the import library to applications that call your DLL.
    Interprets /Fe as naming a DLL rather than an .EXE file; the default program name becomes basename.DLL instead of basename.EXE.
    Changes default run-time library support to /MT if you have not explicitly specified one of the /M options 
    /LDd Not applicable Creates a debug DLL. Defines _DEBUG. 
    To find these options in the development environment, click Settings on the Project menu. Then click the C/C++ tab, and click Code Generation in the Category box. See the Use Run-Time Library drop-down box. The debug options select the debug versions of the library or DLL and define _DEBUG. For more information on using the debug versions, see C Run-Time Debug Libraries.For further discussion of DLLs, see DLL Topics. 
    --------------------------------------------------------------------------------
    Send feedback to MSDN.Look here for MSDN Online resources.