From owner-freebsd-questions Fri Apr 19 12:20:58 1996 Return-Path: owner-questions Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id MAA26019 for questions-outgoing; Fri, 19 Apr 1996 12:20:58 -0700 (PDT) Received: from phaeton.artisoft.com (phaeton.Artisoft.COM [198.17.250.211]) by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id MAA26014 for ; Fri, 19 Apr 1996 12:20:56 -0700 (PDT) Received: (from terry@localhost) by phaeton.artisoft.com (8.6.11/8.6.9) id MAA08755; Fri, 19 Apr 1996 12:18:01 -0700 From: Terry Lambert Message-Id: <199604191918.MAA08755@phaeton.artisoft.com> Subject: Re: How can I use gethostname() in snake_saver ?? To: ATuretta@stylo.it (Angelo Turetta) Date: Fri, 19 Apr 1996 12:18:01 -0700 (MST) Cc: freebsd-questions@freebsd.org In-Reply-To: from "Angelo Turetta" at Apr 19, 96 06:36:07 pm X-Mailer: ELM [version 2.4 PL24] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-questions@freebsd.org X-Loop: FreeBSD.org Precedence: bulk > I'm learning unix programming, so I'm obviously missing some very basic > information: please, be patient :-) > > I've modified snake_saver.c to make it use the host name as its 'snake' > message. The hack is really simple: in saver_load() I use gethostname(3) to > fill a static array that is later used by snake_saver() instead of the local > array 'saves'. > > When I try to install the screen saver using modload(8), I get: > > /usr/src/lkm/syscons/snake> modload -u -o /tmp/saver_mod -e saver_init -q > /lkm/snake_saver_mod.o > /lkm/snake_saver_mod.o: Undefined symbol `_gethostname' referenced from > text segment > modload: /usr/bin/ld: return code 1 > > Is it only some -lxxxx missing or am I pretending too much :-) ???? > > Thanks for any help. gethostname() is a libc function. The screen saver is a kernel module. You need to include and access the control variable "kern.hostname". The C library is not available in the kernel, where the save runs. Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers.