"Symbol Defined More Than Once" Linking Basic & C 6.0 for OS/2 (71244)



The information in this article applies to:

  • Microsoft BASIC Compiler for MS-DOS and OS/2 6.0
  • Microsoft BASIC Compiler for MS-DOS and OS/2 6.0b
  • Microsoft Basic Professional Development System (PDS) for MS-DOS and MS OS/2 7.1

This article was previously published under Q71244

SYMPTOMS

Linking a program compiled by the BC.EXE version 7.1 compiler (shipped with Microsoft Basic PDS version 7.1) with C code compiled with the C version 6.0 or 6.0a compiler, results in a "L2025 : Symbol defined more than once" error at link time under the following conditions:

  1. The Basic code is compiled without the /O switch to use the run-time module.
  2. The Basic code is compiled for OS/2 protected mode (the /Lp compiler switch).
  3. The C code contains the statement #include <stdio.h>.
  4. The C code contains at least one printf statement.
  5. The C code is compiled for medium or large model (the /AM or /AL compiler switches).
  6. The C code is compiled for OS/2 protected mode (the /Lp compiler switch).
  7. The C code and Basic code are linked together using the /NOE (NO Extended library search) switch.
Compiling the Basic and C code for MS-DOS or for OS/2 real mode (the /Lr compiler option) eliminates the LINK error. Compiling the Basic code with /O also eliminates the LINK error. You can also overcome the problem by modifying Basic's protected-mode run-time libraries, as shown further below.

STATUS

Microsoft has confirmed this to be a bug in the Microsoft Basic Professional Development System (PDS) version 7.1 for MS OS/2, and with Microsoft C PDS versions 6.0 and 6.0a for MS OS/2. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

Attempting to link Basic code and C code under the conditions outlined above results in the following symbols being "Defined more than once." The symbols are contained within the C 6.0 default OS/2 protected-mode libraries MLIBCE.LIB (medium model) and LLIBCE.LIB (large model):

STKHQQ
aaltstkovr
aFchkstk

Modifying Basic's Run-time Libraries to Work Around the Problem

A workaround for the problem is to remove the conflicting routines from Basic's protected-mode run-time libraries. This can be accomplished by using the library manager (LIB.EXE) from the MS-DOS command line. To overcome the link error, a copy of the chkstk routine needs to be extracted from the standalone library. The chkstk routine is then added to the run-time library after removing the __chkstk and __aFchkstk routines. Below are the necessary steps to modify each one of Basic's protected-mode run-time libraries.

Emulated Math/Near String Protected-Mode Library

   LIB BCL71ENP *chkstk;
   LIB BRT71ENP -__chkstk-__aFchkstk+chkstk;
				

Emulated Math/Far String Protected-Mode Library

   LIB BCL71EFP *chkstk;
   LIB BRT71EFP -__chkstk-__aFchkstk+chkstk;
				

Alternate Math/Near String Protected-Mode Library

   LIB BCL71ANP *chkstk;
   LIB BRT71ANP -__chkstk-__aFchkstk+chkstk;
				

Alternate Math/Far String Protected-Mode Library

          LIB BCL71AFP *chkstk;
          LIB BRT71AFP -__chkstk-__aFchkstk+chkstk;
				

How to Duplicate the Problem

Below are the necessary steps to duplicate the problem:

BASSIDE.BAS

DECLARE SUB PrintMessage CDECL ()
CALL PrintMessage
END
				

CSIDE.C



#include <stdio.h>
void PrintMessage(void)
{
     printf("Hello world!");
return;
}
				
Compile the above sample code from the MS-DOS command line as follows:
   BC BASSIDE.BAS /Lp;
   CL /AM /c /Lp CSIDE.C
				
Link the Basic and C code together from the MS-DOS command line as follows:
   LINK /NOE BASSIDE.OBJ+CSIDE.OBJ;
				
The preceding link command results in the following errors:

MLIBCE.LIB(chkstk.asm) : L2025 : STKHQQ : symbol defined more than once
MLIBCE.LIB(chkstk.asm) : L2025 : __aaltstkovr : symbol defined more than once
MLIBCE.LIB(chkstk.asm) : L2025 : __aFchkstk : symbol defined more than once

To workaround this problem, compile the Basic code with the /O compiler option to make a stand-alone program. Compiling the Basic code for MS-DOS or OS/2 real mode (the /Lr compiler option) also eliminates the LINK errors.

Modification Type:MajorLast Reviewed:11/18/2003
Keywords:KB71244