什么' f'后缀表示C ++库名称,如何加载?

时间:2014-12-04 16:24:16

标签: c++ posix real-time gperftools

我正在使用gperftools v2.3rc并希望使用改进的线程分析功能。发行说明部分说明:

  现在已经实现了Linux上的新cpu profiling模式。它为单独的线程设置单独的分析定时器。 ...如果同时加载 librt.f 并且设置了CPUPROFILE_PER_THREAD_TIMERS环境变量,则启用[It]。 ...

我的C ++应用程序与librt.so(-lrt - POSIX.1b Realtime Extensions库)链接,但我之前没有听说过带有.f后缀的库。 .f意味着什么,我在哪里可以找到这个库,以及如何在我的应用程序中加载它?

1 个答案:

答案 0 :(得分:5)

我怀疑因缺乏咖啡而导致暂时性关节炎(这是一个错字)。是什么意思是librt.so。从src/profile-handler.cc的中间开始:

// We use weak alias to timer_create to avoid runtime dependency on
// -lrt and in turn -lpthread.
//
// At runtime we detect if timer_create is available and if so we
// can enable linux-sigev-thread mode of profiling

并在代码中进一步向下:

#if HAVE_LINUX_SIGEV_THREAD_ID
  if (getenv("CPUPROFILE_PER_THREAD_TIMERS")) {
    if (timer_create && pthread_once) {  // <-- note this bit here.
      timer_sharing_ = TIMERS_SEPARATE;
      CreateThreadTimerKey(&thread_timer_key);
      per_thread_timer_enabled_ = true;
    } else {
      RAW_LOG(INFO,
              "Not enabling linux-per-thread-timers mode due to lack of timer_create."
              " Preload or link to librt.so for this to work");
    }
  }
#endif

检查是否设置了envvar并且已加载librt。它是关于librt.so。