www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/02/05/17:56:25

From: Jason Green <news AT jgreen4 DOT fsnet DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: A beginner's problem...!
Date: Mon, 05 Feb 2001 22:42:03 +0000
Organization: Customer of Energis Squared
Lines: 53
Message-ID: <j5au7to6ieutsbtuvjh8fm2kpq0rg6aivp@4ax.com>
References: <3A7F202C DOT 12549DCB AT tinyworld DOT co DOT uk>
NNTP-Posting-Host: modem-229.connecticut.dialup.pol.co.uk
Mime-Version: 1.0
X-Trace: newsg1.svr.pol.co.uk 981412923 7849 62.137.58.229 (5 Feb 2001 22:42:03 GMT)
NNTP-Posting-Date: 5 Feb 2001 22:42:03 GMT
X-Complaints-To: abuse AT theplanet DOT net
X-Newsreader: Forte Agent 1.7/32.534
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

KBZDj <KBZDj AT tinyworld DOT co DOT uk> wrote:

>  could any replies be sent
> direct to me because I have not subscribed to the mailing list.

Done.  Note that the mailing list is really just a gateway to the
usenet group comp.os.msdos.djgpp

> PROBLEM
> Using RHIDE, I have 2 c files each of which #includes a header file. The
> code is straight from a Teach Yourself C book. The source files compile,
> but I cannot link them to create an EXE. When building (compiling and
> linking) the files I get the following message:
> 
> Compiling: calc.c
> no errors
> Compiling: list2101.c
> no errors
> Creating test.exe
> Error: calc.o: In function 'sqr':
> calc.c(4) Error:multiple definition of 'sqr'
> o:calc.c(4) Error:first defined here
> Error: collect2: ld returned 1 exit status
> There were some errors

You don't show the compile command (please do that if you still have a
problem) so it's difficult to tell what causes these errors.  Here is
an example of separate compile and link stages:

gcc -O2 -Wall -c list2101.c
gcc -O2 -Wall -c calc.c
gcc list2101.o calc.o -o list2101

Note the -Wall, it would have pointed to some problems in your code:

> int main()

int main(void)

> {
>  int x;
> 
>  printf("Enter an integer value: ");
>  scanf("%d", &x);
>  printf("\nThe square of %d is %ld.\n", x, sqr);

printf("\nThe square of %d is %ld.\n", x, sqr(x));

>  return;

return 0;

> }

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019