Difference between revisions of "Microsoft KB Archive/92869"

From BetaArchive Wiki
m (Text replacement - "<" to "<")
m (Text replacement - ">" to ">")
Line 54: Line 54:
<pre class="CODESAMP">  cl /c /AM /DMOVE_ENV /Gs moveinit.c
<pre class="CODESAMP">  cl /c /AM /DMOVE_ENV /Gs moveinit.c
   link <objs&gt; moveinit.obj,,,movetr.lib,project.def </pre>
   link <objs> moveinit.obj,,,movetr.lib,project.def </pre>
When MOVE_ENV is defined, MOVEAPI.H declares the following variable:
When MOVE_ENV is defined, MOVEAPI.H declares the following variable:

Latest revision as of 10:25, 21 July 2020

PRB: Unresolved External Error Compiling for MOVE Environment


The information in this article applies to:

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


When an application implements the MOVE overlay scheme by defining MOVE_ENV, compiling the MOVEINIT.C file, and linking MOVEINIT.OBJ with the other files of the application, linking fails with the following error message:

L2029: '__movesegenv' unresolved external


The default medium memory model and large memory model libraries do not support MOVE_ENV.


Link the application with the MOVETR.LIB file.


The MOVE overlay scheme supports using environment variables to specify the size of the overlay heap and overlay caches at run time. The MOVEAPI.TXT file distributed with Microsoft C/C++ version 7.0 and the MOVEAPI.WRI file distributed with Microsoft C/C++, versions 8.0 and 8.00c detail the required procedure.

To implement the MOVE overlay scheme, define MOVE_ENV and compile the MOVEINIT.C file. Link the MOVEINIT.OBJ file with MOVETR.LIB and the other files of your application. The text below lists the commands to compile and link the files. Note that the /Gs switch is used to eliminate calls to the stack-checking routine because the initialization in MOVEINIT occurs before the C run-time library initialization occurs.

   cl /c /AM /DMOVE_ENV /Gs moveinit.c
   link <objs> moveinit.obj,,,movetr.lib,project.def 

When MOVE_ENV is defined, MOVEAPI.H declares the following variable:

   extern unsigned short __far __cdecl _movesegenv; 

To avoid receiving an unresolved external error, the application must define the _movesegenv symbol in moveinit() to contain the segment address of the environment. The following three steps define _movesegenv:

  1. Define _movesegenv as a global variable, as follows:

          unsigned short __far _movesegenv; 
  2. Define the OffsetEnv symbol to be the offset in the program segment prefix (PSP) of the segment address of the environment, as follows:

          #define OffsetEnv 2Ch 
  3. Note that MOVEINIT.C is divided into two parts. The first part is compiled when MOVE_ENV is not defined. The second part begins on line 175 and is used when MOVE_ENV is defined. Line 175 is as follows:

          #else /* MOVE_ENV */  

    Make the following two modifications to the start of the moveinit() function in the second part of the file:

    • Retrieve the segment address of the PSP into BX, as follows:

            _asm {
               MOV ah, 51h                     ; Get PSP
               INT 21h
    • Retrieve the address of the environment from the OffsetEnv location in the PSP and store the address in _movesegenv, as follows:

            _asm {
               MOV es, bx                      ; Contains seg of PSP
               MOV ax, WORD PTR es:OffsetEnv   ; Get seg of environment
               MOV bx, SEG _movesegenv         ; Get seg of _movesegenv
               MOV es, bx                      ;     since it is far
               MOV es:_movesegenv, ax          ; Store seg in _movesegenv

Additional query words: 7.00 8.00 8.00c 1.00 1.50 Visual

Keywords : kb16bitonly kbprb
Issue type : kbprb
Technology : kbVCsearch kbAudDeveloper kbPTProdChange kbvc150 kbvc100 kbZNotKeyword3 kbCVC700DOS

Last Reviewed: May 9, 2001
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.