Results 1 to 6 of 6
HEllo guys, the problems I have is that in this little program:
#include <stdio.h>
#include </usr/include/libgtop-2.0/glibtop.h>
#include </usr/include/libgtop-2.0/glibtop/proclist.h>
#include </usr/include/glib-2.0/glib.h>
int main(){
glibtop_init();
//glibtop_cpu cpu;
//glibtop_mem memory;
glibtop_proclist proclist;
//glibtop_get_cpu ...
- 03-17-2010 #1Just Joined!
- Join Date
- Mar 2010
- Posts
- 12
Glibtop libraries, problems with .h
HEllo guys, the problems I have is that in this little program:
#include <stdio.h>
#include </usr/include/libgtop-2.0/glibtop.h>
#include </usr/include/libgtop-2.0/glibtop/proclist.h>
#include </usr/include/glib-2.0/glib.h>
int main(){
glibtop_init();
//glibtop_cpu cpu;
//glibtop_mem memory;
glibtop_proclist proclist;
//glibtop_get_cpu (&cpu);
//glibtop_get_mem(&memory);
int which,arg;
glibtop_get_proclist(&proclist,which,arg);
printf("%ld\n%ld\n%ld\n",
(unsigned long)proclist.number,
(unsigned long)proclist.total,
(unsigned long)proclist.size);
return 0;
}
I compile it, and I start to have these stranges errors in libraries I dont even know
:
(a little example because is huge)
In file included from /usr/include/glib-2.0/glib.h:80,
from /usr/include/libgtop-2.0/glibtop.h:25,
from proclist.c:2:
/usr/include/glib-2.0/glib/gstring.h:45: error: expected specifier-qualifier-list before gchar
/usr/include/glib-2.0/glib/gstring.h:52: error: expected ) before size
/usr/include/glib-2.0/glib/gstring.h:55: error: expected =, ,, ;, asm or __attribute__ before * token
/usr/include/glib-2.0/glib/gstring.h:57: error: expected =, ,, ;, asm or __attribute__ before * token
/usr/include/glib-2.0/glib/gstring.h:60: error: expected =, ,, ;, asm or __attribute__ before * token
/usr/include/glib-2.0/glib/gstring.h:66: error: expected ;, , or ) before * token
/usr/include/glib-2.0/glib/gstring.h:67: error: expected ;, , or ) before * token
/usr/include/glib-2.0/glib/gstring.h:69: error: expected ) before dfl_size
/usr/include/glib-2.0/glib/gstring.h:70: error: expected =, ,, ;, asm or __attribute__ before * token
Any idea?
ANd, if someone has a glibtop functions guide, I will be really gratefull.
Thank you very much.
- 03-19-2010 #2Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
Your #includes are invalid. Do this:
Also, the errors you are getting are indicating that you probably need some #define declared before you include the headers (or a -D name=value in your Makefile's CFLAGS variable).Code:#include <stdio.h> #include <libgtop-2.0/glibtop.h> #include <libgtop-2.0/glibtop/proclist.h> #include <glib-2.0/glib.h>
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 03-27-2010 #3Just Joined!
- Join Date
- Mar 2010
- Posts
- 12
Thanks you man, I will try it.
- 03-27-2010 #4Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
The way you did it is "non-standard", but should work. However, the normal way is to leave the leading "/usr/include/" off of the #include directives for headers found in the /usr/include tree. From the error messages, it was reading those files. In any case, looking at my version of that file, from what I can tell, it seems that possibly the 'gsize' type has not been defined. It should be defined in /usr/include/glib-2.0/glib/gtypes.h or /usr/include/glib-2.0/glib.h - in my case it is in glib.h. So, try reordering your headers like this:
and see what happens.Code:#include <stdio.h> #include <glib-2.0/glib.h> #include <libgtop-2.0/glibtop.h> #include <libgtop-2.0/glibtop/proclist.h>
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 04-14-2010 #5Just Joined!
- Join Date
- Mar 2010
- Posts
- 12
I think I resolve that problem, but now I have another one:
cpu.c:18: error: expected specifier-qualifier-list before guint64
The error is in the first line of the declaration inside the structure.
And also I get this one:
cpu.c:29: error: myCpu undeclared (first use in this function)
inside the glibtop_get_cpu function
and this one in the printf function:
cpu.c:28: warning: incompatible implicit declaration of built-in function printf
In this code:
Any Ideas?Code:#include </usr/include/libgtop-2.0/glibtop.h> #include </usr/include/libgtop-2.0/glibtop/mem.h> #include </home/furiwel/Escritorio/PFC/cpu.h> #include </usr/include/glib-2.0/glib.h> #include <unistd.h> int main(void) { glibtop_init(); typedef struct _glibtop_cpu { guint64 total; /* GLIBTOP_CPU_TOTAL */ guint64 user; /* GLIBTOP_CPU_USER */ guint64 nice; /* GLIBTOP_CPU_NICE */ guint64 sys; /* GLIBTOP_CPU_SYS */ guint64 idle; /* GLIBTOP_CPU_IDLE */ guint64 frequency; /* GLIBTOP_CPU_FREQUENCY */ } glibtop_cpu; void glibtop_get_cpu(glibtop_cpu *myCpu); printf("total:%ld\nuser:%ld\nnice:%ld\nsys:%ld\nidle:%ld\nfrequency:%ld\n", myCpu.total, myCpu.user, myCpu.nice, myCpu.sys, myCpu.idle,myCpu.frequency); glibtop_close(); return(0); }
- 04-14-2010 #6Just Joined!
- Join Date
- Mar 2010
- Posts
- 12
I think I solve those problems, but then:
cpu.c
.text+0xf): undefined reference to `glibtop_init'
cpu.c
.text+0x50): undefined reference to `glibtop_close'
and I have the close.h header.


Reply With Quote