Path: utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!ames!amdahl!pacbell!sactoh0!bkbarret From: bkbarret@sactoh0.UUCP (Brent K. Barrett) Newsgroups: comp.lang.c Subject: Re: TLINK errors (cc/lint were clean) Summary: Must use externs Message-ID: <670@sactoh0.UUCP> Date: 3 Feb 89 03:56:27 GMT References: <44100021@hcx1> Organization: Sacramento Public Access, Ca. USA Lines: 46 In article <44100021@hcx1>, ldh@hcx1.SSD.HARRIS.COM writes: > > Here's one for the UNIX gurus who also know something about TurboC ... > > Have a modularized program lint/cc do not object to the various modules ... TC2 > on the other hand does. > [ Chomp! ]j > When invoked as follows, the TurboC 2.0 linker has a 2 major objections: > tlink \tc2\lib\c0m main module_a module_b,prog,prog,,\tc2\lib\cm > > > 1) variables defined in header.h get linker error messages as follows: > Error: _A defined in module MAIN.C is duplicated in module MODULE_A.C > Error: _A defined in module MAIN.C is duplicated in module MODULE_B.C > > 2) Certain basic stuff ends up being "undefined" > Undefined symbol '_FOPEN' in module MAIN.C > Undefined symbol '_PRINTF' in module MAIN.C > > What is going on?! This is the first time I have tried anything modularized on > TC2 ... Turbo C allows global variables to be declared only ONCE. Every other time they are included in a module, they must be declared as "extern"als. Do the following to solve your problem: 1) Place all your variable declarations into your main.c file as is, then create a file called "extern.h" that lists the same variable declarations prefixed by "extern." e.g.: float j; becomes: extern float j; 2) simply #include "extern.h" in all your modules except main.c. I'm no Unix guru, but that will solve your TC problems. -- "Somebody help me! I'm trapped in this computer!" Brent Barrett ..pacbell!sactoh0!bkbarret GEMAIL: B.K.BARRETT