【发布时间】:2019-01-31 08:26:38
【问题描述】:
我是 C++ 初学者,我正在尝试使用 Visual Studio 2017 和 cmake 在 Windows 32 位上构建 ssh.dll。我已经下载了最新版本的libssh,并在按照推荐的步骤配置和生成后,尝试使用cmake从源代码构建ssh.dll。
生成后,我使用 Visual Studio 2017 打开了 libssh 解决方案文件并构建它,但在编译时出现了一些缺少库的错误,我通过将这些库添加到 VC 路径来解决。
添加这些库后,它开始给我大约 600 个与语法相关的编译错误,如下所示(但这些库文件中的语法看起来是正确的)。
有什么方法或建议可以让我成功解决它们并创建 .dll 文件?
以下是其中一些错误:
Severity Code Description Project File Line Suppression State
Error C2146 syntax error: missing ')' before identifier 'session' ssh_shared c:\apps\mvs15\vc\tools\msvc\14.10.25017\include\libssh\priv.h 196
Error C2061 syntax error: identifier 'channel' ssh_shared c:\apps\mvs15\vc\tools\msvc\14.10.25017\include\libssh\callbacks.h 64
Error C2059 syntax error: ';' ssh_shared c:\apps\mvs15\vc\tools\msvc\14.10.25017\include\libssh\callbacks.h 64
Error C2146 syntax error: missing ')' before identifier 'fd' ssh_shared c:\apps\mvs15\vc\tools\msvc\14.10.25017\include\libssh\libssh.h 656
Error C2059 syntax error: ')' ssh_shared c:\apps\mvs15\vc\tools\msvc\14.10.25017\include\libssh\libssh.h 597
Error C2081 'socket_t': name in formal parameter list illegal ssh_shared c:\apps\MVS15\VC\Tools\MSVC\14.10.25017\include\libssh\poll.h 135
Error C2059 syntax error: '}' ssh_shared c:\apps\MVS15\VC\Tools\MSVC\14.10.25017\include\libssh\session.h 203
Error C2146 syntax error: missing ')' before identifier 'fd' ssh_shared c:\apps\MVS15\VC\Tools\MSVC\14.10.25017\include\libssh\socket.h 36
Error C2059 syntax error: ';' ssh_shared c:\apps\mvs15\vc\tools\msvc\14.10.25017\include\libssh\callbacks.h 64
Error C2037 left of 'iqmp' specifies undefined struct/union 'rsa_st' ssh_shared C:\apps\vcpkg\downloads\libssh-0.7.6.tar\libssh-0.7.6\src\libcrypto-compat.c 77
Error C2037 left of 'dmq1' specifies undefined struct/union 'rsa_st' ssh_shared C:\apps\vcpkg\downloads\libssh-0.7.6.tar\libssh-0.7.6\src\libcrypto-compat.c 76
为了解决这个问题,我还尝试用这些库文件的其他版本替换有问题的库文件,但没有任何运气。接下来我可以尝试什么?
【问题讨论】:
-
你安装了依赖的zlib、openssl库吗?
-
是的。实际上,我在使用
cmake-gui.exe生成解决方案之前安装了zlib和openssl库。但我不知道为什么我必须在我的 VC 文件夹中手动包含库,包括openssl和libssh头文件。 -
你是如何安装它们的? Windows 没有内置的安装 c/c++ 库的约定。
-
@VTT 所以我下载了
libssh源代码并安装了zlib、openssl和cmake。通过将其指向下载的libssh的src父目录来运行cmake-gui.exe,对其进行配置并生成构建。之后,我可以在我的构建文件夹中看到 libssh_solution 文件,该文件在 Visual Studio 2017 中打开以进行编译。最初,缺少库并导致与缺少库相关的错误。那些是'libssh,'openssl`zlib和config.h。我将它们手动添加到我的 VC 路径中,然后再次编译,我开始收到我在 OP 中提到的上述错误
标签: c++ visual-studio cmake visual-studio-2017 libssh