Mail Archives: djgpp/2001/02/05/17:56:25
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 -