linux - 在 linux CPU 负载中包含 glibtop

标签 linux glib

这是我在 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.

The manual说:

-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/

相关文章:

c - 迭代 GList 的宏

java - 编译带有嵌套子类的 Java 类突然不起作用, "access denied"

c++ - 如何检查给定进程在运行时加载了哪些共享库?

linux - 确定正确的/dev/usb/lp*

linux - 如何摆脱 'GLIBCXX_3.4.9 not found error' ?

c++ - 将 int 转换为 Glib::ustring w/o stringstream

gtk - GLib编译错误(ffi.h),但libffi已安装

c - linux中的并行处理

linux - 在 linux 中创建 react-native 应用程序时出错

ios - 为 iPhone 编译 GLib?