在 Linux CPU 负载中包括 glibtop
这是我的代码,用于查看 Linux 中的 CPU 负载,但我有一些错误!我下载了 glibtop 并将其放在与我的程序相同的目录中,但我有这些错误!
`#include "stdio.h"
#include "glibtop.h"
#include "glibtop/cpu.h"
int main(){
glibtop_init();
glibtop_cpu cpu;
glibtop_get_cpu (&cpu);
printf("CPU TYPE INFORMATIONS \n\n"
"Cpu Total : %ld \n"
"Cpu User : %ld \n"
"Cpu Nice : %ld \n"
"Cpu Sys : %ld \n"
"Cpu Idle : %ld \n"
"Cpu Frequences : %ld \n",
(unsigned long)cpu.total,
(unsigned long)cpu.user,
(unsigned long)cpu.nice,
(unsigned long)cpu.sys,
(unsigned long)cpu.idle,
(unsigned long)cpu.frequency);
return 0;
}`
我的错误是:
cpuLoad.c:2:21: error: glibtop.h: No such file or directory
In file included from cpuLoad.c:3:
glibtop/cpu.h:25:21: error: glibtop.h: No such file or directory
glibtop/cpu.h:26:28: error: glibtop/global.h: No such file or directory
In file included from cpuLoad.c:3:
glibtop/cpu.h:59: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before âtypedefâ
glibtop/cpu.h:63: error: expected specifier-qualifier-list before âguint64â
glibtop/cpu.h:84: error: expected â)â before â*â token
glibtop/cpu.h:92: error: expected â)â before â*â token
glibtop/cpu.h:98: error: expected â)â before â*â token
glibtop/cpu.h:99: error: expected â)â before â*â token
cpuLoad.c:9: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before âintâ
你知道问题是什么吗?我不知道我应该如何告诉linux我的.h文件的路径!
Here is my code to see CPU load in linux but I have some errors! I downloaded glibtop and put it in same directory as my program is but I have these errors!
`#include "stdio.h"
#include "glibtop.h"
#include "glibtop/cpu.h"
int main(){
glibtop_init();
glibtop_cpu cpu;
glibtop_get_cpu (&cpu);
printf("CPU TYPE INFORMATIONS \n\n"
"Cpu Total : %ld \n"
"Cpu User : %ld \n"
"Cpu Nice : %ld \n"
"Cpu Sys : %ld \n"
"Cpu Idle : %ld \n"
"Cpu Frequences : %ld \n",
(unsigned long)cpu.total,
(unsigned long)cpu.user,
(unsigned long)cpu.nice,
(unsigned long)cpu.sys,
(unsigned long)cpu.idle,
(unsigned long)cpu.frequency);
return 0;
}`
my errors are:
cpuLoad.c:2:21: error: glibtop.h: No such file or directory
In file included from cpuLoad.c:3:
glibtop/cpu.h:25:21: error: glibtop.h: No such file or directory
glibtop/cpu.h:26:28: error: glibtop/global.h: No such file or directory
In file included from cpuLoad.c:3:
glibtop/cpu.h:59: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before âtypedefâ
glibtop/cpu.h:63: error: expected specifier-qualifier-list before âguint64â
glibtop/cpu.h:84: error: expected â)â before â*â token
glibtop/cpu.h:92: error: expected â)â before â*â token
glibtop/cpu.h:98: error: expected â)â before â*â token
glibtop/cpu.h:99: error: expected â)â before â*â token
cpuLoad.c:9: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before âintâ
do you know what is the problem?I dontr know how should I tell linux the path of my .h files!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
gcc -I.
等手册说:
gcc -I.
etcThe manual says:
我刚刚尝试了上面相同的代码,它的工作就像一个魅力。
它位于 Debian Unstable amd64 上,带有
libgtop2-dev
2.28.4-3 和 gcc 4.7.1。I've just tried the same code above and it works like a charm.
It is on Debian Unstable amd64 with
libgtop2-dev
2.28.4-3 and gcc 4.7.1.