I build GTSAM in Windows and now I am trying to build a sample application with it.
The sample application is very simple (it is part of GTSAM) but when I run it, I am getting this linker error:
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol __imp_clock referenced in function gk_CPUSeconds example D:\MyData\SourceCode\gtsam_win\cmake\example_cmake_find_gtsam\build\metis-gtsamDebug.lib(timers.obj)
and
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol __imp__time64 referenced in function time example D:\MyData\SourceCode\gtsam_win\cmake\example_cmake_find_gtsam\build\metis-gtsamDebug.lib(timers.obj) 1
a search showed me that these two functions are part of MSVC libraries and they should in linked to the system.
How can I fix the issue?
It seems that the problem is mismatch between the setting during library build and application build, but I can not find any linker setting different. Where to look for any such difference?
__imp_
prefix in unresolved external runtime library symbol from the linked library means the library was built with DLL runtime (/MD
in C++ -> Code Generation -> Runtime Library
).
If you build the application with static runtime (/MT
) the symbols from the DLL runtime will be unresolved. Runtime settings should be the same for all compilation units.