cmake:无法链接谷歌分析器(gperftools)

问题描述 投票:0回答:1

我在ubuntu 16.04上。

我在这做了什么:

  1. 安装了gperftools: sudo apt-get install google-perftools libgoogle-perftools-dev
  2. https://github.com/vast-io/vast/blob/master/cmake/FindGperftools.cmake下载了FindGperftools.cmake
  3. FindGperftools.cmake重命名为GperftoolsConfig.cmake并将其放入我的包装中的cmake文件夹中
  4. 添加到CMakelists.txtset (Gperftools_DIR "${CMAKE_CURRENT_LIST_DIR}/cmake/") find_package(Gperftools REQUIRED)
  5. 在相同的CMakelists.txt中,链接我的可执行文件: target_link_libraries(my_executable ${GPERFTOOLS_PROFILER})
  6. 在终端中,导出CPUPROFILE环境变量: export CPUPROFILE=/my_path/prof.out
  7. 在同一个终端中,运行可执行文件: ./my_executable

没有错误消息,但未创建日志文件/my_path/prof.out

如果我在“my_executable”上运行“ldd”,则它不会显示与profiler的任何关联(ldd ./my_executable | grep profil不会产生任何结果)。然而,当查看构建文件夹中的文件时,编译器似乎进行了链接(-lprofile就在那里)。

我可能忘记了什么?

注意:不确定它是否相关,但我使用catkin。

c++ cmake profiler catkin gperftools
1个回答
1
投票

这看起来像ubuntu(和非标准)链接器功能,不链接库直接不使用哪些符号。尝试在LDFLAGS中添加-Wl,-no-as-needed(并确保在-lprofiler之前传递)。

© www.soinside.com 2019 - 2024. All rights reserved.