Microsoft KB Archive/45165

= &quot;Too Many Segments&quot; LINKing More than 128 Modules =

Article ID: 45165

Article Last Modified on 11/21/2006

-

APPLIES TO


 * Microsoft QuickBasic 4.0
 * Microsoft QuickBASIC 4.0b
 * Microsoft QuickBasic 4.5 for MS-DOS
 * Microsoft BASIC Professional Development System 7.0
 * Microsoft BASIC Professional Development System 7.1

-



This article was previously published under Q45165



SUMMARY
The linker error message L1049, &quot;Too many segments,&quot; occurs when you are trying to LINK more than 128 modules into an .EXE program or a Quick library. The default number of segments for LINK.EXE is 128. To correct this problem, combine two or more of the modules (the .BAS source files).

If the modules are too large to combine, you must set the number of segments to more than 128 with the /SEGMENTS linker option. While /SEGMENTS:3072 is the highest allowed value in the LINK syntax, the true practical limit is about 1300 to 1500. If you compile and link within the QuickBasic environment instead of from the DOS command prompt, you can set the /SEGMENTS option by including the following line in your AUTOEXEC.BAT file: set link=/segments: Note that there is no space before or after the = (equal sign). (If this fails, add one space after the equal sign.)

This information applies to Microsoft QuickBasic versions 4.0, 4.0b, and 4.5; to Microsoft Basic Compiler versions 6.0 and 6.0b; and to Microsoft Basic Professional Development System (PDS) versions 7.0 and 7.1.



MORE INFORMATION
To determine the number of segments you are generating, use the following guidelines. A module in QuickBasic is exactly the same as a .BAS file. Each module compiles to one code segment. All of the data in the program is combined at LINK time into one single data segment. There is only one data segment, no matter how many modules you compile; therefore, the number of segments is as follows:

NumberOfSegments = [number of .BAS files you start with] + 1

If you are using a library, each .BAS file that was compiled and put into the library must be included in the above formula.

The &quot;Too many segments&quot; error message can also occur when using the BUILDRTM utility of Basic 6.0 and 6.0b and Basic PDS 7.0 to combine more than 128 modules into a run-time module. This happens because BUILDRTM.EXE uses LINK.EXE to create a run-time module. The workarounds are the same as above; combine one or more modules or SET the LINK environment variable.

Additional query words: QuickBas BasicCom 4.00 4.00b 4.50 6.00 6.00b 7.00 7.10

Keywords: KB45165

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.