How can I compile the /usr/src/usr.sbin/gstat/gstat.c file?

I want to do some minor modifications to it. (The long story is learning how it works and make a python module for fetching diskinfo).

I'm really a newbie when it comes to compile c sources. I've tried the following
[CMD="gcc"]/usr/src/usr.sbin/gstat/gstat.c -o /home/olav/gstat[/CMD]

But that command gave me a long screen with this error message repeated
Code:
undefined reference to `geom_gettree'

I guess it's some kind of a missing library error?

What steps should I take to create a build environment for the gstat application?
 
If you can't for some reason get root and build it in original path, copy it to your home and build by running make there.

% cp -R /usr/src/usr.sbin/gstat ~/
% cd ~/gstat && make
 
You have to link libgeom with your source, try this:
Code:
gcc /usr/src/usr.sbin/gstat/gstat.c -o /home/olav/gstat -ldevstat -lkvm -lgeom -lbsdxml -lsbuf -ledit -lcurses

It's gcc not ggc, the code is linked statically with other libraries, so you have to set them before compile it, best way to start is to read Makefile in its root directory.
 
olav said:
I want to do some minor modifications to it.(The long story is learning how it works and make a python module for fetching diskinfo).

I'm really newbie when it comes to compile c sources.
I've tried the following
[CMD="gcc"]/usr/src/usr.sbin/gstat/gstat.c -o /home/olav/gstat[/CMD]

Why not just use the Makefile already in that directory? Being the official way to build it, everything will get done in the right way:

# cd /usr/src/usr.sbin/gstat
make your modifications
# make install
 
I need to learn more about how a make file works. Are there any "magic" in the make file for the gstat application?
 
Back
Top