构建 GTSAM 示例时,链接器找不到 __imp_clock 和 __imp_time64

Linker can not find __imp_clock and __imp_time64 when building a sample of GTSAM

我在 windows 中构建了 GTSAm,现在我正在尝试用它构建示例应用程序。

示例应用程序非常简单(它是 GTSAM 的一部分)但是当我 运行 它时,我收到此链接器错误:

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)    

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   

搜索显示这两个函数是 MSVC 库的一部分,它们应该链接到系统。

我该如何解决这个问题?

问题似乎是库构建和应用程序构建期间的设置不匹配,但我找不到任何不同的链接器设置。去哪里寻找这样的差异?

链接库中未解析的外部运行时库符号中的

__imp_ 前缀表示该库是使用 DLL 运行时构建的(C++ -> Code Generation -> Runtime Library 中的 /MD)。

如果您使用静态运行时 (/MT) 构建应用程序,则 DLL 运行时中的符号将无法解析。所有编译单元的运行时设置应该相同。