You are not logged in.
Hey guys, I've got a question about ligtop, and viewing processes via C in general.
How come glib-2.0 headers are in /usr/include/glib-2.0/ , but the libgtop.h file includes glib.h? (and NOT glib-2.0/glib.h)
I've given up on trying to use procps as I see there's absolutely no way of using this in Arch - it just doesn't want to link! Keeps giving me the ol' "undefined reference to `openproc'" and all that jazz....
So does anyone have any solutions? Basically I'm trying to list current running proc's via C. If there's any way to get procps to work, that'd be great, as it seems a lot better than libgtop. If not, does anyone have any way to get libgtop working? It *really* annoyed me when I found out that libgtop includes a file that isn't even placed in the correct directory!
Thanks in advanced!
Offline
because libgtop sources use pkg-config to get the include and flags.
$pkg-config --cflags glib-2.0
-I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include
$pkg-config --libs glib-2.0
-lglib-2.0
Give what you have. To someone, it may be better than you dare to think.
Offline
Hey wonder, thanks for the quick reply!
I still can't seem to get it to compile, I've tried:
gcc file.c -o file `pkg-config --cflags glib-2.0`
(and yes, $pkg-config --cflags glib-2.0 does return the correct values)
still getting
file.c:1:21: fatal error: glibtop.h: No such file or directory
If it helps, here's the file itself:
#include <glibtop.h>
int main( int argc, char **argv )
{
glibtop_get_cpu cpu_begin, cpu_end;
glibtop_get_cpu( cpu_begin );
sleep(300);
glibtop_get_cpu( cpu_end );
return 0;
}
Obviously I didn't really fill it up with anytihng, just wanted to see if I can build it using libgtop...
Offline
Okay, disregard the last post, I noticed now a bunch of really dumb errors on my part (like includg "glibtop.h" and not "libgtop-2.0/glibtop.h")
Now that I fixed that, I still get an error:
/usr/include/libgtop-2.0/glibtop.h:44:27: fatal error: libgtopconfig.h: No such file or directory
EDIT: Wow, I'm stupid... okay, fixed it by running
gcc trying.c -o trying -I/usr/include/libgtop-2.0/ `pkg-config --cflags glib-2.0`
and fixing even more code problems.... Man I should get some sleep! *laughs*
Last edited by Spyes (2011-10-23 17:42:31)
Offline
OKay, okay, I promise this will be my last annoying post!
I'm not stuck at the linking part, where I get
undefined reference to `glibtop_get_cpu'
Edit: Ah-ha! Got it! Just had to compile it like so:
gcc file.c -o file -I/usr/include/libgtop-2.0/ -lgtop-2.0 `pkg-config --cflags glib-2.0`
Very sorry to be so annoying about this. Thanks for pointing me in the right direction!
Last edited by Spyes (2011-10-23 17:48:00)
Offline
you should do
gcc file.c -o file `pkg-config --cflags libgtop-2.0` `pkg-config --libs libgtop-2.0`
Give what you have. To someone, it may be better than you dare to think.
Offline
Ahh yeah, that works like a charm! Thanks!
Offline