如何构建和使用Sigar for C / C ++?

时间:2014-12-09 12:06:02

标签: c sigar

由于他们的wiki或Github上没有说明,这就是我尝试过的:

  1. 克隆the git repository
  2. make
  3. 运行examples/cpuinfo.c
  4. cd examples/

    gcc -Wall -I../include -L../build-src -lsigar cpuinfo.c

    它给了我:

    cpuinfo.c:(.text+0x20): undefined reference to `sigar_open'
    cpuinfo.c:(.text+0x33): undefined reference to `sigar_cpu_list_get'
    cpuinfo.c:(.text+0x4d): undefined reference to `sigar_strerror'
    cpuinfo.c:(.text+0xff): undefined reference to `sigar_cpu_list_destroy'
    cpuinfo.c:(.text+0x10b): undefined reference to `sigar_close'
    

    我需要将其链接以解决这些错误?

1 个答案:

答案 0 :(得分:1)

在cpuinfo.c

之后将-lsigar移动到列表的末尾