sprinfall / webcc

Lightweight C++ HTTP client and server library based on Asio for embedding purpose.
GNU Lesser General Public License v3.0
270 stars 61 forks source link

VS编译标准示例报错无法解析的外部符号 #28

Open UnknownObject000 opened 2 years ago

UnknownObject000 commented 2 years ago

我复制了Readme中的完整客户端例子到VS项目中编译,出现”LNK2001 无法解析的外部符号“错误.(服务端代码不会引起这个错误) 以下为错误内容:

已启动重新生成…
1>------ 已启动全部重新生成: 项目: Application Communication Interface, 配置: Release x64 ------
1>Application Communication Interface.cpp
1>Please define _WIN32_WINNT or _WIN32_WINDOWS appropriately. For example:
1>- add -D_WIN32_WINNT=0x0601 to the compiler command line; or
1>- add _WIN32_WINNT=0x0601 to your project's Preprocessor Definitions.
1>Assuming _WIN32_WINNT=0x0601 (i.e. Windows 7 target).
1>webcc.lib(client_session.obj) : error LNK2001: 无法解析的外部符号 __imp_CertCloseStore
1>webcc.lib(client_session.obj) : error LNK2001: 无法解析的外部符号 __imp_CertEnumCertificatesInStore
1>webcc.lib(client_session.obj) : error LNK2001: 无法解析的外部符号 __imp_CertFreeCertificateContext
1>webcc.lib(client_session.obj) : error LNK2001: 无法解析的外部符号 __imp_CertOpenSystemStoreW
1>F:\Application Communication Interface\x64\Release\Application Communication Interface.exe : fatal error LNK1120: 4 个无法解析的外部命令
1>已完成生成项目“Application Communication Interface.vcxproj”的操作 - 失败。
========== 全部重新生成: 成功 0 个,失败 1 个,跳过 0 个 ==========

Projects build report:
  Status    | Project [Config|platform]
 -----------|---------------------------------------------------------------------------------------------------
  Failed    | Application Communication Interface\Application Communication Interface.vcxproj [Release|x64]

Build time 00:00:03.553
Build ended at 2022-02-11 14:53:31

图为VS的“错误列表” image

sprinfall commented 2 years ago

因为你没有用 CMake,有些库得自己指定一下,你这个问题只要链接 Crypt32.lib 就可以了。 我今天改一下吧,在代码里直接用 #pragma 来指定 Crypt32.lib。

Update: 我还是决定不这样改了,还是建议你使用 CMake 构建你自己的项目,然后参照 webcc-integration 来集成。