[BUG] Confusing title in docs/platform_specific_build_instructions.md

Abierto Apto para principiantes
#2,309 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@skryabae ya está trabajando en esto.

Desde el 8/10/2026.

  • #2328 de @skryabae — abierto
  • #2368 de @utkarshpatwa393-sys — abierto
  • #2369 de @LebedevRI — abierto

Evaluación

Dificultad
1/5
Tiempo estimado
Menos de una hora
Aptitud para principiantes
88/100
Tipo de issue
Documentación
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
cmake, cpp

Línea de trabajo

Abre docs/platform_specific_build_instructions.md y lee la sección titulada "Building with Visual Studio 2015, 2017 or 2022" junto con el contexto de build de Windows indicado. Actualiza la documentación para que el encabezado y el texto dejen claro que las instrucciones también se aplican a mingw-w64-ucrt-x86_64 y, después, verifica que la sección renderizada ya no resulte engañosa.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Describe the bug
In the file https://github.com/google/benchmark/blob/main/docs/platform_specific_build_instructions.md, there is a section titled "Building with Visual Studio 2015, 2017 or 2022". The instructions are not specific to Visual Studio, and the heading is therefore misleading.

I am working on Windows 11 25H2 and using the mingw-w64-ucrt-x86_64-toolchain for compilation and linking: gcc 16.1.0, ld 2.46; and ninja 1.13.2 for the build.

I built the library using the tools mentioned above and then tried to run the code from the "Usage" section of the README, linking against the static library build/src/libbenchmark.a.

The code snippet:

#include <benchmark/benchmark.h>

static void BM_StringCreation(benchmark::State& state) {
  for (auto _ : state)
    std::string empty_string;
}
// Register the function as a benchmark
BENCHMARK(BM_StringCreation);

// Define another benchmark
static void BM_StringCopy(benchmark::State& state) {
  std::string x = "hello";
  for (auto _ : state)
    std::string copy(x);
}
BENCHMARK(BM_StringCopy);

BENCHMARK_MAIN();

Compilation:

D:\Projects\cpptest>c++ main.cpp -isystem "D:/Projects/benchmark/include" -L"D:/Projects/benchmark/build/src" -lbenchmark -lpthread -o main.exe
D:/Programm/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/16.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\egor\AppData\Local\Temp\cctoO03V.o:main.cpp:(.text+0x66): undefined reference to `__imp__ZN9benchmark5State16StartKeepRunningEv'
D:/Programm/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/16.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\egor\AppData\Local\Temp\cctoO03V.o:main.cpp:(.text+0xed): undefined reference to `__imp__ZN9benchmark5State17FinishKeepRunningEv'
D:/Programm/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/16.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\egor\AppData\Local\Temp\cctoO03V.o:main.cpp:(.text+0x198): undefined reference to `__imp__ZN9benchmark5State16StartKeepRunningEv'
D:/Programm/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/16.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\egor\AppData\Local\Temp\cctoO03V.o:main.cpp:(.text+0x229): undefined reference to `__imp__ZN9benchmark5State17FinishKeepRunningEv'
D:/Programm/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/16.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\egor\AppData\Local\Temp\cctoO03V.o:main.cpp:(.text+0x28f): undefined reference to `__imp__ZN9benchmark23MaybeReenterWithoutASLREiPPc'
D:/Programm/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/16.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\egor\AppData\Local\Temp\cctoO03V.o:main.cpp:(.text+0x2ca): undefined reference to `__imp__ZN9benchmark16PrintDefaultHelpEv'
D:/Programm/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/16.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\egor\AppData\Local\Temp\cctoO03V.o:main.cpp:(.text+0x2df): undefined reference to `__imp__ZN9benchmark10InitializeEPiPPcPFvvE'
D:/Programm/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/16.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\egor\AppData\Local\Temp\cctoO03V.o:main.cpp:(.text+0x2f1): undefined reference to `__imp__ZN9benchmark27ReportUnrecognizedArgumentsEiPPc'
D:/Programm/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/16.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\egor\AppData\Local\Temp\cctoO03V.o:main.cpp:(.text+0x305): undefined reference to `__imp__ZN9benchmark22RunSpecifiedBenchmarksEv'
D:/Programm/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/16.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\egor\AppData\Local\Temp\cctoO03V.o:main.cpp:(.text+0x30e): undefined reference to `__imp__ZN9benchmark8ShutdownEv'
D:/Programm/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/16.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\egor\AppData\Local\Temp\cctoO03V.o:main.cpp:(.text+0x32d): undefined reference to `__imp__ZN9benchmark8internal17InitializeStreamsEv'
D:/Programm/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/16.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\egor\AppData\Local\Temp\cctoO03V.o:main.cpp:(.text+0x378): undefined reference to `__imp__ZN9benchmark8internal25RegisterBenchmarkInternalESt10unique_ptrINS_9BenchmarkESt14default_deleteIS2_EE'
D:/Programm/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/16.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\egor\AppData\Local\Temp\cctoO03V.o:main.cpp:(.text+0x3dc): undefined reference to `__imp__ZN9benchmark8internal25RegisterBenchmarkInternalESt10unique_ptrINS_9BenchmarkESt14default_deleteIS2_EE'
D:/Programm/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/16.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\egor\AppData\Local\Temp\cctoO03V.o:main.cpp:(.text$_ZN9benchmark8internal17FunctionBenchmarkC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPFvRNS_5StateEE[_ZN9benchmark8internal17FunctionBenchmarkC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPFvRNS_5StateEE]+0x22): undefined reference to `__imp__ZN9benchmark9BenchmarkC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE'
D:/Programm/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/16.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\egor\AppData\Local\Temp\cctoO03V.o:main.cpp:(.text$_ZN9benchmark8internal17FunctionBenchmarkC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPFvRNS_5StateEE[_ZN9benchmark8internal17FunctionBenchmarkC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPFvRNS_5StateEE]+0x2b): undefined reference to `__imp__ZTVN9benchmark8internal17FunctionBenchmarkE'
collect2.exe: error: ld returned 1 exit status

I was able to fix the error using the solution described in this Stack Overflow post: https://stackoverflow.com/questions/78600881/undefined-references-when-linking-google-benchmark-with-g-on-windows-msys2-u?newreg=d8053eb47e674ea6a805c335e7e46134

I spent a relatively large amount of time troubleshooting this issue because the section heading in https://github.com/google/benchmark/blob/main/docs/platform_specific_build_instructions.md#building-with-visual-studio-2015-2017-or-2022 is misleading and suggests that the instructions are only relevant to Visual Studio.

I think it would be worth mentioning that these instructions are also applicable to mingw-w64-ucrt-x86_64.

System
Which OS, compiler, and compiler version are you using:

  • OS: Windows 11 25H2
  • Compiler and version: gcc 16.1.0, ld 2.46

To reproduce
Steps to reproduce the behavior:

  1. git clone https://github.com/google/benchmark.git && cd benchmark
  2. do README Installation instruction with -G Ninja when generating the build system with cmake
  3. create file with code snippet from README Basic usage section and try to compile it with command proposed in the same section below/

Expected behavior
Successful compilation and linkage

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

Lenguaje dominante
C++
Estrellas
10.5k
Forks
1.8k
Merge medio
1 d 15 h
PR fusionados (30 d)
28

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de google/benchmark

Todos los issues de google/benchmark

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.