我需要使用C/C++语言在程序中获取处理器编号.我的密码
如下所示:

 #include <unistd.h>
 int main()
 {
    int processorNum = sysconf(_SC_NPROCESSORS_CONF);
    return 0;
 }

当我编译它时,它有两个错误:

error: '_SC_NPROCESSORS_CONF' was not declared in this scope
error: 'sysconf' was not declared in this scope

所以我该怎么做.

ps:我的编译器版本是gcc版本4.3.2(Debian 4.3.2-1.1).我应该链接库文件吗


ps:大家好,对不起,我犯了一些错误.我忘了头文件.

解决方法:

1,最可靠的方法是读取/ proc / cpuinfo文件.像grep处理器proc / cpuinfo

2,使用命令lscpu

标签: linux

相关文章推荐

添加新评论,含*的栏目为必填