Registrations are now open. Join us today!
There is still a lot of work to do on the wiki yet! More information about editing can be found here.
Already have an account?

Microsoft KB Archive/103714

From BetaArchive Wiki
Knowledge Base


PRB: LNK4016: Unresolved External Symbol "__doserrno"

Article ID: 103714

Article Last Modified on 11/21/2006



APPLIES TO

  • Microsoft Foundation Class Library 4.2, when used with:
    • Microsoft Visual C++ 1.0 Professional Edition
    • Microsoft Visual C++ 2.0 Professional Edition
    • Microsoft Visual C++ 2.1



This article was previously published under Q103714


SYMPTOMS

Building a project with Visual C++ 1.0 generates the following unresolved link error for __doserrno:

LNK4016: unresolved external symbol "__doserrno"

Under Visual C++ 2.0 and 2.1, the following error is generated:

LNK2001: unresolved external symbol "__doserrno"

NOTE: This behavior does not occur in MFC 4.0 included with Visual C++ version 4.0 as MFC 4.0 supports multithreaded applications by default.

CAUSE

This error may be caused by compiling an application with /MT or /MD (multithreaded options) and linking with the default versions of the Microsoft Foundation Class (MFC) libraries. The default versions of the MFC libraries were not built with the multithreaded C run-time library, which results in the above error.

The MFC Libraries do not support calling MFC code from any thread other than the primary thread. You can make calls to the MFC libraries or global AFX helper functions only from the primary thread.

RESOLUTION

The README.WRI file (installed by default in the \MSVCNT\ directory) describes how to remedy this problem. There are two possible solutions:

  • Rebuild a custom version of the MFC libraries with /MT or /MD defined. For information on building libraries, see the section "Using the New Run-Time Libraries" on page xx-xxi in the "Class Library Reference" manual. (Note that the README.WRI incorrectly references this section as the "Class Library User's Guide.")

    For example, to build the library NAFXCWD.LIB, use following the command:

          NMAKE DEBUG=1 TARGET=W OPT="/MT" CODEVIEW=1
                                

    -or-

  • Rebuild the application using the single-threaded run-time library LIBC.LIB. To select the single-threaded run-time library, choose the Runtime category in the C/C++ Compiler Options dialog box.



Additional query words: 1.00 2.00 2.10 LNK2001

Keywords: kbprb KB103714