这是我在 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 文件的路径!
最佳答案
gcc -I.
等
-I dir Add the directory dir to the list of directories to be searched for header files.
关于linux - 在 linux CPU 负载中包含 glibtop,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8043071/