Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using benchmark port fails linking when using benchmark::benchmark_main #27673

Closed
monamimani opened this issue Nov 6, 2022 · 2 comments · Fixed by #27779
Closed

Using benchmark port fails linking when using benchmark::benchmark_main #27673

monamimani opened this issue Nov 6, 2022 · 2 comments · Fixed by #27779
Assignees
Labels
category:port-bug The issue is with a library, which is something the port should already support

Comments

@monamimani
Copy link

Describe the bug
I believe you now have to define BENCHMARK_STATIC_DEFINE if you are producing a static lib.
When linking against benchmark::benchmark_main I get those unresolved external symbol.

_Out\build\windows-vs2022\benchmark_main.lib(benchmark_main.cc.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl benchmark::PrintDefaultHelp(void)" (__imp_?PrintDefaultHelp@benchmark@@YAXXZ) referenced in function main 
Out\build\windows-vs2022\benchmark_main.lib(benchmark_main.cc.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl benchmark::Initialize(int *,char * *,void (__cdecl*)(void))" (__imp_?Initialize@benchmark@@YAXPEAHPEAPEADP6AXXZ@Z) referenced in function main 
_Out\build\windows-vs2022\benchmark_main.lib(benchmark_main.cc.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl benchmark::Shutdown(void)" (__imp_?Shutdown@benchmark@@YAXXZ) referenced in function main 
_Out\build\windows-vs2022\benchmark_main.lib(benchmark_main.cc.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) bool __cdecl benchmark::ReportUnrecognizedArguments(int,char * *)" (__imp_?ReportUnrecognizedArguments@benchmark@@YA_NHPEAPEAD@Z) referenced in function main 
_Out\build\windows-vs2022\benchmark_main.lib(benchmark_main.cc.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) unsigned __int64 __cdecl benchmark::RunSpecifiedBenchmarks(void)" (__imp_?RunSpecifiedBenchmarks@benchmark@@YA_KXZ) referenced in function main 
D_Out\build\windows-vs2022\benchmark_main.lib(benchmark_main.cc.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) int __cdecl benchmark::internal::InitializeStreams(void)" (__imp_?InitializeStreams@internal@benchmark@@YAHXZ) referenced in function "void __cdecl benchmark::internal::`dynamic initializer for 'stream_init_anchor''(void)" (??__Estream_init_anchor@internal@benchmark@@YAXXZ) 
_Out\build\windows-vs2022\_bin\Debug\ApplicationCoreBenchmarks.exe : fatal error LNK1120: 6 unresolved externals 

Environment

  • OS: Windows

To Reproduce
Steps to reproduce the behavior:

  1. link against benchmark::benchmark_main
  2. build

Expected behavior
No linker error

@Cheney-W Cheney-W self-assigned this Nov 7, 2022
@Cheney-W Cheney-W added the category:port-bug The issue is with a library, which is something the port should already support label Nov 7, 2022
@gjasny
Copy link
Contributor

gjasny commented Nov 9, 2022

Maybe cherry-pick this PR google/benchmark#1470

@gjasny
Copy link
Contributor

gjasny commented Nov 11, 2022

v1.7.1 was just released containing the aforementioned fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:port-bug The issue is with a library, which is something the port should already support
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants