From owner-freebsd-questions Wed Dec 22 13:46:48 1999 Delivered-To: freebsd-questions@freebsd.org Received: from typhoon.mail.pipex.net (typhoon.mail.pipex.net [158.43.128.27]) by hub.freebsd.org (Postfix) with SMTP id ACC7D14D67 for ; Wed, 22 Dec 1999 13:46:45 -0800 (PST) (envelope-from mark@dogma.freebsd-uk.eu.org) Received: (qmail 3912 invoked from network); 22 Dec 1999 21:46:43 -0000 Received: from userbk68.uk.uudial.com (HELO marder-1.) (62.188.144.76) by smtp.dial.pipex.com with SMTP; 22 Dec 1999 21:46:43 -0000 Received: (from mark@localhost) by marder-1. (8.9.3/8.8.8) id VAA01156; Wed, 22 Dec 1999 21:46:47 GMT (envelope-from mark) Date: Wed, 22 Dec 1999 21:46:47 +0000 From: Mark Ovens To: "Ronald 'Ko' Klop" Cc: freebsd-questions@freebsd.org Subject: Re: Q: using kvm gives a compile error Message-ID: <19991222214646.G322@marder-1> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0pre2i In-Reply-To: Organization: Total lack of Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Wed, Dec 22, 1999 at 09:41:56PM +0100, Ronald 'Ko' Klop wrote: > Hello, > > I'm trying to write a program using kvm. > But even the simplest program failes to compile. > > Here is my program iftest.cc: > #include > #include > #include > #include > > int main(int argc,char **argv) { > char *nlistf=NULL,*memf=NULL; > kvm_t *kvmd; > > kvmd = kvm_open(nlistf,memf,NULL,O_RDONLY,"kvm: "); > if (kvmd==NULL) { > printf("error opening kvm\n"); > exit(0); > } > kvm_close(kvmd); > return 0; > } > > > Compiling gives the following output: > g++ iftest.cc > /var/tmp/ccOV18281.o: In function `main': > /var/tmp/ccOV18281.o(.text+0x26): undefined reference to `kvm_open' > /var/tmp/ccOV18281.o(.text+0x55): undefined reference to `kvm_close' > > I have read the man pages searched the mail archive, but didn't find > anything. I also looked at the implementation of top and netstat. > But couldn't find a clue about what I am forgetting. > > Does somebody know how to do this? > You need to link in the kvm library: marder-1# g++ iftest.cc /tmp/ccKh11401.o: In function `main': /tmp/ccKh11401.o(.text+0x26): undefined reference to `kvm_open' /tmp/ccKh11401.o(.text+0x55): undefined reference to `kvm_close' marder-1# g++ iftest.cc -lkvm marder-1# ./a.out marder-1# > Greetings, > > Ronald. > > PS: I'm trying to do this to get the number of send/received bytes across > the ethernet from the kernel. > > -- > Ronald Klop > http://node11a94.a2000.nl/~ronald/ > > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-questions" in the body of the message -- "there's a long-standing bug relating to the x86 architecture that allows you to install Windows too" -Matthew D. Fuller ________________________________________________________________ FreeBSD - The Power To Serve http://www.freebsd.org My Webpage http://ukug.uk.freebsd.org/~mark/ mailto:mark@ukug.uk.freebsd.org http://www.radan.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message