首页 > 解决方案 > ''没有这样的文件或目录' 'cmake' 从源代码为 C++ 中的 libssh 0.8.2 生成成功后?

问题描述

我有 libssh 0.8.2 和 cmake 3.12.2。

通过使用 cmake 中的 generate 选项成功完成构建。cmake在这个过程之后没有生成ssh.lib文件,但是生成了一些文件(ALL_BUILd,INSTALL,ssh_shared,ZERO_CHECK)。

因此,在成功生成 cmake 后,我点击了 cmake 中的“打开项目”选项。在 Visual Studio C++ 中编译文件时,它显示两个错误No such file or directory

Severity    Code    Description Project File    Line    Suppression State
Error   MSB3073 The command "setlocal
"C:\Program Files\CMake\bin\cmake.exe" -DBUILD_TYPE=Debug -P cmake_install.cmake
if %errorlevel% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
:cmErrorLevel
exit /b %1
:cmDone
if %errorlevel% neq 0 goto :VCEnd
:VCEnd" exited with code 1. INSTALL C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets   133 

标签: c++visual-c++sshcmakelibssh

解决方案


您是否仍在使用libssh-0.8.2/src目录中的 CMakeLists.txt (正如我从您之前的问题中推测的那样)?那是错的。CMakeLists.txt您需要使用目录中的顶层libssh-0.8.2

此项目的每个目录级别都可能包含一个CMakeLists.txt. 包含该project语句的那个​​可能是您需要使用的那个。Visual Studio 解决方案文件 ( .sln) 的生成可以通过命令行从顶级目录 ( libssh-0.8.2) 中完成cmake . -Bbuilddir -G "Visual Studio 15 2017 Win64"。根据 INSTALL 文件中的文档,您可能需要在此调用中添加-DOPENSSL_ROOT_DIR=C:\Users\Sami\<install path here>和。-DZLIB_ROOT_DIR=C:\Users\Sami\<install path here>

稍后您可以使用cmake --build builddir --target ALL_BUILD --config Release. 成功构建后,您可以使用cmake --build builddir --target INSTALL --config Release.


推荐阅读