[comp.sys.ibm.pc] Turbo C Linking Problem

smvorkoetter@watmum.waterloo.edu (Stefan M. Vorkoetter) (11/10/87)

I am having problems linking a program with TURBO C.  The program consists
of about 15 source files.  Each and every one compiles, but when I link,
I get an error when CH.LIB is being linked in that there is too much global
data defined in a file.  None of my files defines more than 64K of global
data.  As a matter of fact, the entire program uses less than 64K of global
data.  Unfortunately, it won't even tell me which file is the supposed
culprit.  I have double checked that the model is selected properly, and that
everything else is set right.  I am running under the integrated environment.

By the way, the program I am compiling is a C compiler that I am developing.
Perhaps this is Borland's way of preventing competition :-)

Any help on this matter would be appreciated.  The program compiles fine
under 4.3 BSD.  I am not doing anything the least bit esoteric anywhere.

Thanks in advance,
Stefan Vorkoetter
Symbolic Computation Group
University of Waterloo
(smvorkoetter@watmum.waterloo.edu)

jsin@CS.UCLA.EDU (11/11/87)

I also have a problem linking under TC. I have one file with few procedures,
and the program compiles ok. But when I link the .OBJ file to get .EXE file,
the Linker gives me "module _main unresolved" or some such nonsense.
Of course, main() is in my file and it compiles and runs fine using other
compilers, such as Mark Williams C compiler(I can't afford MSC).

I did get TC to link it using the TLINK (command line linker) finally.
Is this a known bug? Or did I do something wrong?

Thanks to all who respond.
                                                John


John (Jonghoon) Sin
UCLA SEASnet Facilities   ARPA:   jsin@seas.ucla.edu
2567 Boelter Hall         BITNET: jsin%seas.ucla.edu@wiscvm.wisc.edu
Los Angeles, CA. 90025    UUCP:   ...!{ihnp4,ucbvax,{hao!cepu}}!ucla-cs!jsin
(213) 206-6864

jep@oink.UUCP (James E. Prior) (11/13/87)

I have a solution to the TURBO C Linking Problem.

In article <2293@watcgl.waterloo.edu> smvorkoetter@watmum.waterloo.edu (Stefan M. Vorkoetter) writes:
>
>I am having problems linking a program with TURBO C.  The program consists
>of about 15 source files.  Each and every one compiles, but when I link,
>I get an error when CH.LIB is being linked in that there is too much global
>data defined in a file.  None of my files defines more than 64K of global
>data.  As a matter of fact, the entire program uses less than 64K of global
>data.  Unfortunately, it won't even tell me which file is the supposed
>culprit.  I have double checked that the model is selected properly, and that
>everything else is set right.  I am running under the integrated environment.
>
>By the way, the program I am compiling is a C compiler that I am developing.
>Perhaps this is Borland's way of preventing competition :-)
>
>Any help on this matter would be appreciated.  The program compiles fine
>under 4.3 BSD.  I am not doing anything the least bit esoteric anywhere.
>
>Thanks in advance,
>Stefan Vorkoetter
>Symbolic Computation Group
>University of Waterloo
>(smvorkoetter@watmum.waterloo.edu)

I had a similar problem with Turbo C, and have a way of coping with it.

I was working on a program with much data.  I was already using the
compact memory model (64K code, 1M data).  I added more and more
arrays of initialized structures.  Eventually, the linker complained
that I had too much global data.  I split the arrays into many modules,
so that every module was well under 64K of initialized data.  It still
croaked.  I changed from Turbo's TC environment to conventional command
line invokations of tcc and tlink.  Tlink would always croak.  I switched
to the huge model.  It is supposed to handle more than 64K of 
initialized data.  It still croaked, both in the tc environment and by
tcc and tlink.

I finally called Borland's technical support number, and they knew both
the problem and the solution.  The problem is a bug in their tlink
program.  The solution is to use the ordinary link program.  Their
support staff didn't waste anyone's time.  My entire call was under five
minutes.  They were smart.  They asked the right questions.

Following are excerpts from my makefile, that *do* work for me.

# huge memory model: 1M code, 1M data
MODEL=h
CFLAGS=-Ic:\tc -m$(MODEL) -c

jem2set.exe:			\
.
. dependencies omitted
.
	rem tlink /c /m /s ..\c0$(MODEL) @obj.lst, jem2set.exe,, ..\cusrc\a$(MODEL)curses ..\emu ..\math$(MODEL) ..\C$(MODEL)
	\msc4\link /NOI /STACK:4096 /SEGMENT:256 ..\c0$(MODEL) @obj.lst, $*,$*, ..\cusrc\a$(MODEL)curses ..\emu ..\math$(MODEL) ..\C$(MODEL)

BTW, I used Polymake since I have used it for years.  I didn't feel
like messing with Turbo make, so I can't say anything good or bad about
it.

Warning: There are an amazing number of link.exe's by Microsoft.  I used
the one that came with Microsoft C 4.0 .  I doubt that some of the older
versions will work, especially the ones supplied with DOS.
-- 
James E. Prior  {ihnp4|cbosgd}!n8emr!oink!jep

peter@csd4.csd.uwm.edu (Peter J Diaz de Leon) (01/22/90)

	I am trying to link several object moduals that were
	compiled in Turbo C 2.0 using tlink. However, I keep 
	getting the error

		Fatal:Comman arguments too long

	I assmue that DOS only allows a line to be just so long.
	How do I get around this?  A copy of the tlink line
	that give an error is also included.

					Thanks
					Peter

        tlink c0m closure.obj error.obj lalr.obj lr0.obj main.obj mkpar.obj output.obj reader.obj skeleton.obj symtab.obj verbose.obj warshall.obj ,byacc,mbyacc,cm
Fatal: Command arguments too long



==============================================================================
ARPA: peter@csd4.csd.uwm.edu       USMAIL: Peter J. Diaz de Leon
      peter@cvax.cs.uwm.edu                7411 W. Warnimont Ave.
			                    Milwaukee, WI. 53220
==============================================================================

josephc@tybalt.caltech.edu (Joseph Chiu) (01/22/90)

peter@csd4.csd.uwm.edu (Peter J Diaz de Leon) writes:

>        tlink c0m closure.obj error.obj lalr.obj lr0.obj main.obj mkpar.obj output.obj reader.obj skeleton.obj symtab.obj verbose.obj warshall.obj ,byacc,mbyacc,cm
>Fatal: Command arguments too long

I suggest you look in the manual on the specifics, but Turbo C allows you to
have various configuration information in the file TURBOC.CFG to allow lots
of commands (and probably file names) to be specified.  Also, if you look
in the manual, there is a way to enter all the filenames through yet another
file. (Sort of like a make).

My advice is to put every .obj's into a library of your own, then link c0m with
your main.obj and let the library take care of itself from there.

Joseph

cs4g6ag@maccs.dcss.mcmaster.ca (Stephen M. Dunn) (01/22/90)

In article <1997@uwm.edu> peter@csd4.csd.uwm.edu (Peter J Diaz de Leon) writes:
$	I am trying to link several object moduals that were
$	compiled in Turbo C 2.0 using tlink. However, I keep 
$	getting the error
$		Fatal:Comman arguments too long
$	How do I get around this?  A copy of the tlink line

   Use a response file.  For details of how to do this, check out the
documentation that came with your copy of Turbo C.  I've never used
this feature of the linker, so I don't know offhand how to do it.

-- 
Stephen M. Dunn                               cs4g6ag@maccs.dcss.mcmaster.ca
          <std_disclaimer.h> = "\nI'm only an undergraduate!!!\n";
****************************************************************************
       "I want to look at life - In the available light" - Neil Peart

leoh@hardy.hdw.csd.harris.com (Leo Hinds) (01/23/90)

In article <1997@uwm.edu> peter@csd4.csd.uwm.edu (Peter J Diaz de Leon) writes:

>		Fatal:Comman arguments too long

>	I assmue that DOS only allows a line to be just so long.

127 characters is the limit ... fixes? ... I would like to hear some myself ...


leoh@hdw.csd.harris.com                  H    H     i                 d   sssss
L        eeeee    oooo                   H    H          nnnn     ddddd   ss
L        eee     o    o                  HHHHHH     i    n   n   d    d     ss
LLLLLL   eeeee    oooo                   H    H     i    n    n   ddddd  sssss

platt@ndla.UUCP (Daniel E. Platt) (01/23/90)

In article <1997@uwm.edu>, peter@csd4.csd.uwm.edu (Peter J Diaz de Leon) writes:
> 	I am trying to link several object moduals that were
> 	compiled in Turbo C 2.0 using tlink. However, I keep 
> 	getting the error

> 		Fatal:Comman arguments too long


....
The command was:


>         tlink c0m closure.obj error.obj lalr.obj lr0.obj main.obj mkpar.obj output.obj reader.obj skeleton.obj symtab.obj verbose.obj warshall.obj ,byacc,mbyacc,cm

This looks familiar... perhaps bison? or was it kermit?... I don't remember...


> Fatal: Command arguments too long


This message is occuring because you have too many arguments.  I'm afraid
that if you want to use the Borland products, you have to use 'tlib' to
create a library, and submit that as an argument for linking (can be done
directly from 'tcc').


-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
||                                     1(914)945-1173            ||
||        Dan Platt                    1(914)941-2474            ||
||        Watson (IBM)                 PLATT@YKTVMV.BITNET       ||
||                           ..!uunet!bywater!scifi!ndla!platt   ||
||                                                               ||
||     The opinions expressed here do not necessarily reflect    ||
||                   those of my employer!                       ||
||                                                               ||
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

leif@comcon.UUCP (Leif Sawyer ) (01/23/90)

In article <25BAB7FC.13768@maccs.dcss.mcmaster.ca>, cs4g6ag@maccs.dcss.mcmaster.ca (Stephen M. Dunn) writes:
> In article <1997@uwm.edu> peter@csd4.csd.uwm.edu (Peter J Diaz de Leon) writes:
> $	I am trying to link several object moduals that were
> $	compiled in Turbo C 2.0 using tlink. However, I keep 
> $	getting the error
> $		Fatal:Comman arguments too long
> $	How do I get around this?  A copy of the tlink line
> 
>    Use a response file.  For details of how to do this, check out the
> documentation that came with your copy of Turbo C.  I've never used
> this feature of the linker, so I don't know offhand how to do it.
> 

Using a response file is pretty simple. For the first few time you do it, 
it may be simpler to modify a 'quicky'.  
From dos:
c:\turboc\source> tcc dummy.c
  tcc.......
  compiling...
  linking...
c:\turboc\source> del dummy.obj
c:\turboc\source> del dummy.exe
c:\turboc\source> qu turboc.$ln

this is a temp file used by tcc to call tlink.
here's an example one:
d:\turboc\source> type turboc.$ln

d:\turboc\lib\c0m.obj+
mcvert+
hqxify+
unpack
mcvert
/c/v/x
d:\turboc\lib\EMU.LIB+
d:\turboc\lib\mathm.lib+
d:\turboc\lib\cm.lib

d:\turboc\source>

as you can see, the first line is the startup module, c0x, where x is the
code model. next is the list of .OBJ files to be linked together. multiple
files are concatenated by the use of a '+' (plus) sign at the end of the 
filename. a filename with no '+' denotes the last .OBJ file to be included.
Next is the .EXE filename. After that is the line containing any options
that have been passed to the linker-defaulting to /x(ecutible file), /v(debug),
/c(ase significant).  After the option line is a list of library files to 
include, starting with any user-defined libraries, then the defaults.
The same rule of multiple files applies to the .LIB files as to the .OBJ files.


Hope this helps out some!
 
-- 
:- From Leif Sawyer  ----  USnail -= 1568 Primrose/Anch/AK/99508-3062        -:
:- UUCP - uunet!comcon!leif1       "Does the name Pavlov ring a bell? "      -:
:- BitNet - ASLAS@Alaska.BitNet                 #define flame /dev/null      -:
:-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-:

cooper@plains.UUCP (Jeff Cooper) (01/24/90)

I use 4DOS, it allows 255 characters on the command line, and also lets
you use aliases (like csh on UNIX).

Jeff Cooper
l

ralf@b.gp.cs.cmu.edu (Ralf Brown) (01/24/90)

In article <3173@plains.UUCP> cooper@plains.UUCP (Jeff Cooper) writes:
}I use 4DOS, it allows 255 characters on the command line, and also lets
}you use aliases (like csh on UNIX).

Unfortunately, only the first 126 characters of the command tail can be
passed to external programs; this is a limitation of DOS.  Unless the program
has been written to check the CMDLINE environment variable, it won't see the
rest of the command line.

Of course, the longer command line means that the program name doesn't reduce
the length of the command tail that can be passed to the program (since
COMMAND.COM uses a DOS call which is limited to 127 characters to get the
input line).

-- 
{backbone}!cs.cmu.edu!ralf   ARPA: RALF@CS.CMU.EDU   FIDO: Ralf Brown 1:129/46
BITnet: RALF%CS.CMU.EDU@CMUCCVMA   AT&Tnet: (412)268-3053 (school)   FAX: ask
DISCLAIMER? | _How_to_Prove_It_ by Dana Angluin  24. by appeal to intuition:
What's that?| Cloud-shaped drawings frequently help here.