使用make install安装libssh构建时出错

时间:2018-11-14 00:18:02

标签: cmake gnu-make libssh

OS和CMake的历史记录

我正在尝试在Debian GNU / Linux 9.5上安装libssh。我已经使用cmake成功构建了libssh源,并将所有内容放入安装手册中建议的build目录中。 (请注意,我没有使用zlib构建源,因为它只是可选的)。注意:使用cmake构建源时没有错误。

Install Manual of libssh

问题:make install错误

安装手册现在提示您通过运行

来安装libssh
  

进行安装

build目录中

。现在,如果执行此操作,则会收到以下错误消息:

[ 84%] Linking CXX executable libsshpp_noexcept
CMakeFiles/libsshpp_noexcept.dir/libsshpp_noexcept.cpp.o: In function `main':
libsshpp_noexcept.cpp:(.text+0xb2): undefined reference to `std::cout'
libsshpp_noexcept.cpp:(.text+0xb7): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
libsshpp_noexcept.cpp:(.text+0xcd): undefined reference to `std::cout'
libsshpp_noexcept.cpp:(.text+0xd2): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
libsshpp_noexcept.cpp:(.text+0xdc): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
libsshpp_noexcept.cpp:(.text+0xe7): undefined reference to `std::ostream::operator<<(std::ostream& (*)(std::ostream&))'
CMakeFiles/libsshpp_noexcept.dir/libsshpp_noexcept.cpp.o: In function `__static_initialization_and_destruction_0(int, int)':
libsshpp_noexcept.cpp:(.text+0x163): undefined reference to `std::ios_base::Init::Init()'
 libsshpp_noexcept.cpp:(.text+0x178): undefined reference to `std::ios_base::Init::~Init()'
 CMakeFiles/libsshpp_noexcept.dir/libsshpp_noexcept.cpp.o:(.data.DW.ref.__gxx_personality_v0[DW.ref.__gxx_personality_v0]+0x0): undefined reference to `__gxx_personality_v0'
collect2: error: ld returned 1 exit status
examples/CMakeFiles/libsshpp_noexcept.dir/build.make:96: recipe for target 'examples/libsshpp_noexcept' failed
make[2]: *** [examples/libsshpp_noexcept] Error 1
CMakeFiles/Makefile2:431: recipe for target 'examples/CMakeFiles/libsshpp_noexcept.dir/all' failed
make[1]: *** [examples/CMakeFiles/libsshpp_noexcept.dir/all] Error 2
Makefile:149: recipe for target 'all' failed
make: *** [all] Error 2

是什么原因导致此问题,该如何解决?

1 个答案:

答案 0 :(得分:0)

libssh构建在../libssh/build/examples中包含一些有关如何使用该库的示例文件。如果要使用make install安装libssh,则Makefile2中的../libssh/build/CMakeFiles已指定示例文件也随安装一起编译。现在的问题是这些示例文件内部存在一些错误,这就是为什么libssh的编译/安装可以解决上述问题中所述的错误。

现在要解决此问题,您必须删除libsshpp_noexcept.dir文件夹中的libsshpp.dir../libssh/build/examples/CMakeFiles。为了使安装成功,您还必须删除Makefile2(在../libssh/build/CMakeFiles内部)中负责编译这两个示例文件的相应代码行。在您首选的文本编辑器中打开Makefile2,然后在文件中搜索examples/CMakeFiles/libsshpp_noexcept.dir/buildexamples/CMakeFiles/libsshpp.dir/build。现在,您必须删除检查和安装/编译这两个文件/目录的所有内容。我删除了以下部分:

  

#=============================================== ====

     

删除此处的所有内容

     

...

     

#=============================================== ====

通过删除分隔符内部的内容,可以删除libssh提供的两个(不是必需的)示例文件的安装/编译过程。

现在在make install内运行../libssh/build,您应该一切顺利。