Getting linker error on while using benchmark.lib in Visual Studio 2017

977 views
Skip to first unread message

gaur...@gmail.com

unread,
Aug 6, 2017, 3:06:44 PM8/6/17
to benchmark-discuss
Hello,
I am quite new to C++ development and see benchmark as quite promising library to use in development.
I have build benchmark.lib using CMake project in Visual Studio 2017. Later, I am trying to run some sample examples develop my understanding.
But facing linker ERROR

My Code:

#include "stdafx.h"
#include <benchmark\benchmark.h>
#include <benchmark\benchmark_api.h>
#include <benchmark\reporter.h>


static void BM_StringCreation(benchmark::State& state) {
while (state.KeepRunning())
std::string empty_string;
}
// Register the function as a benchmark
BENCHMARK(BM_StringCreation);

BENCHMARK_MAIN()

-------------------------------------------------------------

ERROR I am getting:


1>------ Build started: Project: HelloWorld, Configuration: Debug Win32 ------
1>stdafx.cpp
1>HelloWorld.cpp
1>benchmark.lib(sysinfo.obj) : error LNK2019: unresolved external symbol __imp__SHGetValueA@24 referenced in function "void __cdecl benchmark::`anonymous namespace'::InitializeSystemInfo(void)" (?InitializeSystemInfo@?A0x2d55634d@benchmark@@YAXXZ)
1>c:\users\lenovo\documents\visual studio 2017\Projects\HelloWorld\Debug\HelloWorld.exe : fatal error LNK1120: 1 unresolved externals
1>Done building project "HelloWorld.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

------------------------------------------------------------

I have already verified that benchmark.lib file path and name is correctly configured.

Can someone please look into this?

Dominic Hamon

unread,
Aug 14, 2017, 1:53:53 PM8/14/17
to gaur...@gmail.com, benchmark-discuss
the missing symbol is described in https://msdn.microsoft.com/en-us/library/windows/desktop/bb773495(v=vs.85).aspx. From that, I'd guess you're missing some library dependency on your project on Shlwapl.lib.

Dominic Hamon | Google
There are no bad ideas; only good ideas that go horribly wrong.


--
You received this message because you are subscribed to the Google Groups "benchmark-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to benchmark-discuss+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages