APPNOTE: Patch, Allocate, Mixed-Language Windows Programming

Last reviewed: February 16, 1996
Article ID: Q78522
The information in this article applies to:
  • Microsoft FORTRAN for MS-DOS, version 5.1

SUMMARY

This application note corrects the unresolved externals that may occur when linking a mixed-language Windows program using FORTRAN and C. If the FORTRAN code uses the ALLOCATE statement, LINK may generate the following errors:

   LINK : error L2029:  Unresolved external: _hfree
   LINK : error L2029:  Unresolved external: _hmalloc

To obtain the application note "PATCH: Allocate in Mixed-Language Windows Programming," call Microsoft Product Support Services.

This application note is also available in the Microsoft Software Library. Download HF0484.EXE, a self-extracting file, from the Microsoft Software Library (MSL) on the following services:

  • Microsoft Download Service (MSDL)

          Dial (206) 936-6735 to connect to MSDL
          Download HF0484.EXE (size: 18675 bytes) 
    
  • Internet (anonymous FTP)

          ftp ftp.microsoft.com
          Change to the \softlib\mslfiles directory
          Get HF0484.EXE (size: 18675 bytes) 
    

MORE INFORMATION

The following is the text of the application note:

    Microsoft Product Support Services Application Note (Text File)
     HF0484: PATCH: ALLOCATE IN MIXED-LANGUAGE WINDOWS PROGRAMMING
                                                  Revision Date: 11/91
                                                         Disk Included

The following information applies to FORTRAN version 5.1.

 --------------------------------------------------------------------
| INFORMATION PROVIDED IN THIS DOCUMENT AND ANY SOFTWARE THAT MAY    |
| ACCOMPANY THIS DOCUMENT (collectively referred to as an            |
| Application Note) IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY      |
| KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO    |
| THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A     |
| PARTICULAR PURPOSE. The user assumes the entire risk as to the     |
| accuracy and the use of this Application Note. This Application    |
| Note may be copied and distributed subject to the following        |
| conditions: 1) All text must be copied without modification and    |
| all pages must be included; 2) If software is included, all files  |
| on the disk(s) must be copied without modification [the MS-DOS(R)  |
| utility DISKCOPY is appropriate for this purpose]; 3) All          |
| components of this Application Note must be distributed together;  |
| and 4) This Application Note may not be distributed for profit.    |
|                                                                    |
| Copyright 1991 Microsoft Corporation. All Rights Reserved.         |
| Microsoft, MS-DOS, and the Microsoft logo are registered           |
| trademarks and Windows is a trademark of Microsoft Corporation.    |
 --------------------------------------------------------------------

This application note corrects a problem that occurs when you link a mixed-language Windows program using FORTRAN and C. If the FORTRAN code uses the ALLOCATE statement, LINK generates two errors:

   LINK : error L2029:  Unresolved external: _hfree
   LINK : error L2029:  Unresolved external: _hmalloc

The errors are caused by the absence of several routines in the C- compatible FORTRAN run-time library. To correct this problem, you must add to the C-compatible FORTRAN run-time library the three object modules that are included on the enclosed HF0484 disk.

Modifying the C-Compatible FORTRAN Run-Time Library

To make the correction to the C-compatible FORTRAN run-time library, copy the following three object modules from the enclosed HF0484 disk to the directory where your FORTRAN library is located:

   WHALLOC.OBJ
   WHSEG.OBJ
   HMAP.OBJ

Then, enter the following command

   LIB <LIBNAME.LIB> + WHALLOC.OBJ + WHSEG.OBJ + HMAP.OBJ;

where <LIBNAME.LIB> represents the name of the C-compatible FORTRAN run-time library you want to modify. You can then delete the three object modules from the library directory. The library manager will make a backup file named <LIBNAME.BAK>. When the new library has been tested successfully, you can also delete this backup file.


Additional reference words: 5.10 HF0484.EXE
KBCategory: kbtool kbappnote kbfile
KBSubcategory: FLIss


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: February 16, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.