FIX: L2029 Error Calling ODBC Functions from ODBC SDK

Last reviewed: September 16, 1997
Article ID: Q108522
7.00 | 1.00 MS-DOS | WINDOWS kbtool kbbuglist kbfixlist

The information in this article applies to:

  • Microsoft C/C++ for MS-DOS, version 7.0
  • Microsoft Visual C++ for Windows, version 1.0

SYMPTOMS

When building an application using the ODBC Software Development Kit (SDK), linker error L2029 "unresolved external" may occur on calls made to ODBC functions.

CAUSE

Several header files included with the ODBC SDK are missing extern "C" statements, which are needed to make them compatible with a C++ compiler. The functions residing in the ODBC libraries do not have decorated names, and therefore the extern "C" statement is necessary if you are calling the functions from an application written in C++.

The following header files are affected by this problem:

   SQL.H
   SQLEXT.H
   ODBCINST.H
   ODBCVER.H

RESOLUTION

There are two ways to handle this problem:

  • Modify the ODBC header files to include the missing extern "C" statements. For example:

          #ifdef __cplusplus
    
          extern "C" {   /* Assume C declarations for C++ */
          #endif
              .
              .  // The body of the header file goes here.
              .
          #ifdef __cplusplus
          }
          #endif
    
       This is the preferred way of handling this situation. This
       solution will correct the problem permanently.
    
       -or-
    
    
  • Wrap the include statements in your own program where these header files are brought in. For example:

          extern "C" {
          #include <SQL.H>
          #include <SQLEXT.H>
          ....
          }
    

    This method of working around the problem should be used on a temporary basis only. This method will allow you to link successfully, but each time one of these header files is included in your program, it will need to be wrapped by an extern "C" statement.

STATUS

Microsoft has confirmed this to be a problem in the products listed at the beginning of this article. The problem was corrected in Visual C++ for Windows version 1.5 by including new versions of the four header files listed above.


Additional reference words: 1.00 1.50 7.00 8.00 8.00c
KBCategory: kbtool kbbuglist kbfixlist
KBSubcategory: CPPIss
Keywords : CPPIss kb16bitonly kbbuglist kbfixlist kbtool
Version : 7.00 | 1.00
Platform : MS-DOS WINDOWS
Solution Type : kbfix


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 16, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.