Microsoft KB Archive/41004

From BetaArchive Wiki
Knowledge Base

"UNRESOLVED EXTERNAL"; Can't Call External from Quick Library

Article ID: 41004

Article Last Modified on 11/21/2006


  • Microsoft QuickBasic 4.0
  • Microsoft QuickBASIC 4.0b
  • Microsoft QuickBasic 4.5 for MS-DOS
  • Microsoft BASIC Compiler 6.0
  • Microsoft BASIC Compiler 6.0b
  • Microsoft BASIC Professional Development System 7.0

This article was previously published under Q41004


Routines in a Quick library are not allowed to call procedures that are external to that Quick library. If you manually execute LINK with the /QU option to make a Quick library and you get an "Unresolved External" error, then the CALL statement in the Quick library that calls that routine is skipped at run time.

A Quick library (which has the filename extension .QLB) is essentially an executable file, but it cannot be invoked directly from DOS or from an .EXE program compiled in Basic. A Quick library can only be used within the QuickBasic QB.EXE or Basic PDS 7.00 QBX.EXE environments.


When you manually execute LINK with the /QU option to attempt to make a Quick library that tries to CALL a routine that is not in the .OBJ list or .LIB library list, then the error message "UNRESOLVED EXTERNAL" is properly displayed at LINK time. Despite the "UNRESOLVED EXTERNAL" message, the linker still creates a Quick library (.QLB file). This Quick library runs properly in the QB.EXE or QBX.EXE environment without giving any error messages. However, the CALL statement in the Quick library that calls the routine that was reported as an "UNRESOLVED EXTERNAL" is skipped at run time.

If you attempt to make a Quick library from inside QB.EXE or QBX.EXE (by using the Make Library command on the Run menu), the error message "Subprogram not defined" prevents the creation of the Quick library that has an "UNRESOLVED EXTERNAL."

The following steps illustrate this limitation:

  1. Compile the subprogram TEMP5.BAS as follows:

          BC TEMP5.BAS;

    (Compile with the /Fs (far strings) option if you are using Basic PDS 7.00, since the QBX.EXE environment always uses far strings).

  2. Make the Quick library TEMP5.QLB as follows in QuickBasic Version 4.50:

          LINK TEMP5.OBJ,,,BQLB45.LIB/QU

    (Link with BQLB40.LIB in QuickBasic Version 4.00; BQLB41.LIB in QuickBasic Version 4.00b; or QBXQLB.LIB in Basic PDS 7.00).

  3. Invoke the QB.EXE or QBX.EXE editor with the TEMP5.QLB Quick library as follows:

          QB MAIN/L TEMP5

    (Or QBX MAIN /L TEMP5 if using Basic PDS Version 7.00)

  4. When you run the MAIN.BAS program in QB.EXE, the Quick library subroutine TEMP5 attempts to call INMAIN (which is a subprogram in the main program), but the CALL INMAIN statement is skipped. The program successfully continues.

The CALL INMAIN statement runs successfully if you LINK MAIN.OBJ+TEMP5.OBJ outside of the editor and run MAIN.EXE from DOS. (You can create MAIN.OBJ as follows: BC MAIN.BAS;).

The following is MAIN.BAS:

DECLARE SUB temp4 ()
PRINT "main"
CALL temp5
PRINT "Inside inmain subprogram."

The following is TEMP5.BAS, which is made into a Quick library:

PRINT "Inside temp5 subprogram"
CALL inmain  ' This CALL is skipped when run within a Quick Library,
             ' but works fine if you link the .OBJ file into a .EXE.
PRINT "End of temp5 subprogram"

Additional query words: QuickBas BasicCom

Keywords: KB41004