windows系统上安装配置google benchmark

google benchmark主要是对c++中的函数进行基准功能测试的库,它需要自己安装。

可以测试代码的性能。

经过两天的努力,终于在windows上配置成功。

下载地址:

  github:https://github.com/google/benchmark

  gitee:https://gitee.com/mirrors/google-benchmark

安装步骤:(官方复制过来的,该步骤本没有错)

复制代码
 1 # Check out the library.
 2 $ git clone https://github.com/google/benchmark.git
 3 # Go to the library root directory
 4 $ cd benchmark
 5 # Make a build directory to place the build output.
 6 $ cmake -E make_directory "build"
 7 # Generate build system files with cmake, and download any dependencies.
 8 $ cmake -E chdir "build" cmake -DBENCHMARK_DOWNLOAD_DEPENDENCIES=on -DCMAKE_BUILD_TYPE=Release ../
 9 # or, starting with CMake 3.13, use a simpler form:
10 # cmake -DCMAKE_BUILD_TYPE=Release -S . -B "build"
11 # Build the library.
12 $ cmake --build "build" --config Release
复制代码

我遇到的问题:

  由于是直接在github上下载下来的 它后面的test什么的都会从github上下载,从而导致有些东西可能下载不完全,所以每次

cmake --build "build" --config Release

的时候,总是会报错,对于这个问题的解决方法,就是使用gitee上的模板来下载。(我是按照下面的步骤来安装成功的)
复制代码
 1 # Check out the library.
 2 $ git clone https://gitee.com/mirrors/google-benchmark.git
 3 # Go to the library root directory
 4 $ cd benchmark
 5 # Make a build directory to place the build output.
 6 $ cmake -E make_directory "build"
 7 # Generate build system files with cmake, and download any dependencies.
 8 $ cmake -E chdir "build" cmake -DBENCHMARK_DOWNLOAD_DEPENDENCIES=on -DCMAKE_BUILD_TYPE=Release ../
 9 # or, starting with CMake 3.13, use a simpler form:
10 # cmake -DCMAKE_BUILD_TYPE=Release -S . -B "build"
11 # Build the library.
12 $ cmake --build "build" --config Release
复制代码

安装好之后,可以按照官方文档配置全局变量,即可使用。

因为我使用的是clion编译器,同时配合cmake,所以要在CMakeLists.txt里面添加一些配置。(该配置官方文档里面有)

如果你也使用了cmake,切记 

target_link_libraries
一定要写在配置文件的最后面!!!

样例:

  

 

 

 

 


posted @   莴苣&  阅读(1002)  评论(1编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!

喜欢请打赏

扫描二维码打赏

了解更多

点击右上角即可分享
微信分享提示