🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: be.comp.programming
Article #10096

gcc probleemke

#10096
From: Bart Vandewoestyne
Date: Sun, 31 Mar 2002 17:14
94 lines
3298 bytes
Ik zit met volgende files:

--------------------------------------------------------
/*
 * algorithms.h: header file for the algorithms module
 */

/* Compute greatest common divisor of a and b */
unsigned int gcd(unsigned int a, unsigned int b);

/* Compute least common multiple of a and b */
unsigned int lcm(unsigned int a, unsigned int b);

-------------------------------------------------------

/*
 * algorithms.c: implementation of the algorithms
 */

#include "algorithms.h"

/*
 * Calculate the greatest common disivor of a and b
 */
unsigned int gcd(unsigned int a, unsigned int b) {
  
  unsigned int result;
  
  if (b == 0) {
    result = a;
  } else {
    result = gcd(b, a%b);
  }
  return result;
}


/*
 * Calculate the least common multiple of a and b
 */
unsigned int lcm(unsigned int a, unsigned int b) {
  
  int result;

  result = a/(gcd(a,b)*b);
  
  return result;
}

-------------------------------------------------------------

/*
 * main.c: main application
 */
#include <stdio.h>
#include "algorithms.h"

main()
{
  unsigned int N1, N2;

  printf("Geef het eerste getal: ");
  scanf("%u", &N1);
  printf("Geef het tweede getal: ");
  scanf("%u", &N2);

  printf("De grootste gemene deler is: %u\n", gcd(N1, N2));
  printf("Het kleinste gemeen veelvoud is: %u\n", lcm(N1, N2));
}

------------------------------------------------------------------

Als ik main.c probeer te compileren krijg ik:
mc303@forsythe:~/2cw/syst_prog/practicum2$ gcc main.c 
/tmp/cc96dmS6.o: In function `main':
/tmp/cc96dmS6.o(.text+0x5d): undefined reference to `gcd'
/tmp/cc96dmS6.o(.text+0x83): undefined reference to `lcm'
collect2: ld returned 1 exit status


Het is al een tijdje geleden dat ik nog in C gewerkt heb... wat zie ik
hier over het hoofd?
Ik snap niet waarom mijn main geen weet heeft van die gcd en lcm
functies...

Greetzzz,
mc303

-- 
Ing. Bart Vandewoestyne			 Bart.Vandewoestyne@pandora.be
Hugo Verrieststraat 48			       GSM: +32 (0)478 397 697
B-8550 Zwevegem			 http://users.pandora.be/vandewoestyne
----------------------------------------------------------------------
"Any fool can know, the point is to understand." - Albert Einstein
Technical Details
Message-ID: <3CA743FA.F9B401AB@pandora.be>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!supernews.com!wn2feed!worldnet.att.net!204.71.34.3!newsfeed.cwix.com!skynet.be!skynet.be!ossa.telenet-ops.be!afrodite.telenet-ops.be.POSTED!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fcea4,445f663aa5c7931a,start
X-Google-Attributes: gidfcea4,public
X-Google-ArrivalTime: 2002-03-31 09:14:38 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!supernews.com!wn2feed!worldnet.att.net!204.71.34.3!newsfeed.cwix.com!skynet.be!skynet.be!ossa.telenet-ops.be!afrodite.telenet-ops.be.POSTED!not-for-mail
Message-ID: <3CA743FA.F9B401AB@pandora.be>
From: Bart Vandewoestyne <Bart.Vandewoestyne@pandora.be>
Organization: MyHome
X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.4.18 i686)
X-Accept-Language: nl-BE, nl, en, de
MIME-Version: 1.0
Newsgroups: be.comp.programming
Subject: gcc probleemke
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Lines: 94
Date: Sun, 31 Mar 2002 17:14:36 GMT
NNTP-Posting-Host: 213.224.224.89
X-Complaints-To: abuse@telenet.be
X-Trace: afrodite.telenet-ops.be 1017594876 213.224.224.89 (Sun, 31 Mar 2002 19:14:36 MET DST)
NNTP-Posting-Date: Sun, 31 Mar 2002 19:14:36 MET DST