ID: Q87545
5.30 | 5.31 | 5.30 MS-DOS | OS/2 | WINDOWS
The information in this article applies to:
In the Microsoft Windows operating system, an attempt to load an mixed- language program build with Microsoft C/C++ version 7.0 and Microsoft FORTRAN version 5.1 fails and Windows generates a general protection (GP) fault.
The application was built with Microsoft LINK version 5.3 and includes the following statement in its module-definition (.DEF) file:
APPLOADER '__MSLANGLOAD'
The error occurs when the file contains unresolved externals. Because the
internal flag that indicates unresolved externals is overwritten by the
routine that resolves the custom loader, no error message occurs when
unresolved externals remain nor is the error bit set in the executable
file.
If Windows version 3.1 is the target operating system, remove the APPLOADER statement from the .DEF file and relink. If Windows version 3.0 is the target operating system, remove the APPLOADER statement from the .DEF file and relink. If no errors occur, edit the .DEF file to place the APPLOADER statement back into the .DEF file and relink.
Microsoft has confirmed this to be a problem in LINK version 5.3 for MS-DOS and Windows (distributed with Microsoft C/C++ version 7.0) and LINK version 5.31 for OS/2. This problem was corrected in LINK version 5.31.009 (distributed with the C/C++ version 7.0a patch disk). To obtain the patch disk, obtain a disk from Microsoft. To obtain a disk in the United States, call Microsoft Product Support Services at (206) 454-2030. Outside the United States, contact the Microsoft subsidiary for your area. To locate your subsidiary, go to the Microsoft Web site http://www.microsoft.com/worldwide/default.htm
The APPLOADER statement in the .DEF file instructs LINK to replace the default loader provided by Windows with a custom loader. The FORTRAN run- time library includes a custom loader called _MSLANGLOAD. This loader enables an application to load huge static data (static data items larger than 64K each) in Windows 3.0. Because the Windows 3.1 loader can load huge static data, the APPLOADER statement is not required.
Mixed-language programs built with C/C++ version 7.0 and FORTRAN version 5.1 must include an additional library, OLDNAMES.LIB, that is not required when the application is built with Microsoft C version 6.0. This requirement is a frequent cause of unresolved external errors, especially in projects that linked successfully when built with C 6.0. Under normal circumstances, an unresolved external error sets an error bit in the executable file, which prevents the Windows loader from attempting to load the incomplete executable file.
The following sample project demonstrates this problem. Note that the code calls the SUB2 subroutine but does not include any code with which to resolve the call. LINK version 5.3 does not generate any error; LINK version 5.15 correctly generates the following error message:
error L2029: 'SUB2' : unresolved external
C Compile options required: fl /c /MW test.for
C Link command line: link /NOD test,,, llibfew, test.def
program test
call sub2
end
NAME TEST WINDOWAPI
APPLOADER '__MSLANGLOAD'
EXETYPE WINDOWS 3.0
STUB 'WINSTUB.EXE'
PROTMODE
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD MOVEABLE
HEAPSIZE 1024
STACKSIZE 8096
Additional reference words: 5.30
KBCategory:
KBSubcategory: LinkIss
Keywords : kberrmsg kb16bitonly LinkIss
Version : 5.30 | 5.31 | 5.30
Platform : MS-DOS OS/2 WINDOWS
Solution Type : kbfix
Last Reviewed: May 22, 1998