리눅스에서 CPU로드를 확인하는 코드는 다음과 같습니다. 그러나 몇 가지 오류가 있습니다! glibtop을 다운로드하고 내 프로그램과 동일한 디렉토리에 넣으십시오. 그러나이 오류가 있습니다!리눅스 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â
당신이 문제가 무엇인지 알고 내가 내 .H 파일의 경로를 리눅스 말해야한다 방법을 알고 dontr?!
어떻게 gtop을 설치 했습니까? fedora를 사용한다면, yum을 사용하십시오. 데비안 또는 우분투 사용자 인 경우 apt-get을 사용하여 설치하십시오. –