• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Platform Specific Build Instructions
2
3## Building with GCC
4
5When the library is built using GCC it is necessary to link with the pthread
6library due to how GCC implements `std::thread`. Failing to link to pthread will
7lead to runtime exceptions (unless you're using libc++), not linker errors. See
8[issue #67](https://github.com/google/benchmark/issues/67) for more details. You
9can link to pthread by adding `-pthread` to your linker command. Note, you can
10also use `-lpthread`, but there are potential issues with ordering of command
11line parameters if you use that.
12
13On QNX, the pthread library is part of libc and usually included automatically
14(see
15[`pthread_create()`](https://www.qnx.com/developers/docs/7.1/index.html#com.qnx.doc.neutrino.lib_ref/topic/p/pthread_create.html)).
16There's no separate pthread library to link.
17
18## Building with Visual Studio 2015 or 2017
19
20The `shlwapi` library (`-lshlwapi`) is required to support a call to `CPUInfo` which reads the registry. Either add `shlwapi.lib` under `[ Configuration Properties > Linker > Input ]`, or use the following:
21
22```
23// Alternatively, can add libraries using linker options.
24#ifdef _WIN32
25#pragma comment ( lib, "Shlwapi.lib" )
26#ifdef _DEBUG
27#pragma comment ( lib, "benchmarkd.lib" )
28#else
29#pragma comment ( lib, "benchmark.lib" )
30#endif
31#endif
32```
33
34Can also use the graphical version of CMake:
35* Open `CMake GUI`.
36* Under `Where to build the binaries`, same path as source plus `build`.
37* Under `CMAKE_INSTALL_PREFIX`, same path as source plus `install`.
38* Click `Configure`, `Generate`, `Open Project`.
39* If build fails, try deleting entire directory and starting again, or unticking options to build less.
40
41## Building with Intel 2015 Update 1 or Intel System Studio Update 4
42
43See instructions for building with Visual Studio. Once built, right click on the solution and change the build to Intel.
44
45## Building on Solaris
46
47If you're running benchmarks on solaris, you'll want the kstat library linked in
48too (`-lkstat`).