LNK1254, LNK1284, and LNK1235 linker errors may occur while compiling a C source file with the /clr compiler option (822329)
The information in this article applies to:
- Microsoft Visual C++ .NET (2003)
- Microsoft Visual C++ .NET (2002)
SYMPTOMSWhen you compile a C source file (unmanaged source) with
other managed source files that refer to symbols that are defined in the
unmanaged source, and you specify the /clr compiler switch, you receive the following linker error message
in Visual C++ .NET 2002: LINK : fatal error LINK1254:
metadata for symbol symbol name inconsistent with
COFF symbol table You receive the following linker errors in Visual
C++ .NET 2003: <managed object
file>: fatal error LNK1284: metadata inconsistent with COFF
symbol table: symbol '<symbol-name>'
(0A000008) mapped to '<symbol-name>'
(06000001) in <unmanaged object
file> <unmanaged object file>: fatal
error LNK1235: corrupt or invalid COFF symbol table CAUSEThe
earlier versions of Visual C++ may not support the C or C++ source files with
the /clr switch because earlier versions of Visual C++ do not have
managed code or the /clr switch.RESOLUTIONCompile the unmanaged source (including the C source files)
into an object file. Similarly, compile files that constitute the managed files
of the project into another object file. Link the object files that are
generated from the managed and unmanaged source files into a single executable
by using the linker. The following steps assume that you have unmanaged source
in UnManaged.c and that you have managed source in Managed.cpp. To build your
project, follow these steps:
- Compile UnManaged.c with the following command:
cl /c UnManaged.c - Compile Managed.cpp with the following command:
cl /clr /c Managed.cpp - Link the object files that are generated in steps 1 and 2
with the following command:
link /NODEFAULTLIB:LIBC Managed.obj UnManaged.obj
STATUS This
behavior is by design.
Modification Type: | Minor | Last Reviewed: | 1/17/2006 |
---|
Keywords: | kbCompiler kbAppDev kbprb KB822329 kbAudDeveloper |
---|
|