Microsoft KB Archive/71244

= &quot;Symbol Defined More Than Once&quot; Linking Basic & C 6.0 for OS/2 =

Article ID: 71244

Article Last Modified on 11/18/2003

-

APPLIES TO


 * Microsoft BASIC Compiler 6.0
 * Microsoft BASIC Compiler 6.0b
 * Microsoft BASIC Professional Development System 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 &quot;L2025 : Symbol defined more than once&quot; 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 .
 * 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 &quot;Defined more than once.&quot; 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
void PrintMessage(void) {    printf(&quot;Hello world!&quot;); 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:
 * 1) include 

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.

Additional query words: BasicCom S_C buglist7.10 6.00 6.00a protect mode (bas2c supplement) 7.10

Keywords: KB71244

-

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

© Microsoft Corporation. All rights reserved.