Daniel Elliott

Using google benchmark with homebrew gcc on OSX


First thing that the google benchmark doesn’t do is tell you which include file you need!

#include "benchmark/benchmark.h"

Apple Clang

For the apple clang that comes with xcode you can just use….

Then to download the library, just use ‘brew install google-benchmark’

Then in cmake you can just use


and then when you link you link with
target_link_libraries(${PROJECT_NAME} benchmark )


Homebrew GCC

If you want to use this library with gcc then the one from homebrew wont work. You’ll get errors when you compile.

You can build it yourself. git clone from github and then build with this command line

then you can make -8 and make install. Now gcc will compile with the library (make sure to uninstall the brew version).

Leave a Reply

Your email address will not be published. Required fields are marked *