对于我为 g++ 编写的项目,我在 MSVC 中遇到了链接问题。这是问题所在:
我将 libssh 构建为静态库作为我的应用程序的一部分,在 cmake 中添加目标
add_library(ssh_static 静态 $libssh_SRCS)
Libssh 在 C 中,所以我在我的 c++ 源代码中包含了 'extern "C" {...}'。然后我将 ssh_static 目标链接到我的可执行文件 sshconnectiontest,使用
target_link_libraries(sshconnectiontest ... ssh_static ...)
这一切都可以在带有 gcc 的 linux 中正常工作,但现在在 MSVC 中我得到了
error LNK2019: unresolved external symbol __imp__[function names here] referenced in [filename]
对于我使用的每个 libssh 函数。
任何想法出了什么问题?我在某处读到imp前缀意味着链接器期望链接一个 .dll,但这不应该是这种情况,因为 ssh_static 在 add_library 调用中被声明为静态库......