filipdobro
filipdobro

Reputation: 3

Error when installing libssh build with make install

OS and CMake prehistory

I'm trying to installlibssh on Debian GNU/Linux 9.5. I have successfully built the libssh source with cmake and put all the content inside build dir that I had created as advised in the install manual. (Note that I did not built the source with zlib as it is only optional) Note: There was no error when building the source with cmake.

Install Manual of libssh

Problem: Error with make install

The install manual now prompts you to install libssh by running

make install

in the build dir. Now if I do that I get the following error message:

[ 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

What is causing this issue and how can I resolve it?

Upvotes: 0

Views: 1009

Answers (1)

pr0f3ss
pr0f3ss

Reputation: 537

The libssh build has some example files inside ../libssh/build/examples on how to use the library. If you want to install libssh with make install, the Makefile2 inside ../libssh/build/CMakeFiles has specified that the example files are also compiled with your installation. Now the problem was that these example files have some errors inside, which is why the compilation/installation of libssh resolved in the error stated in the question above.

Now to resolve this issue you have to delete the libsshpp_noexcept.dir and libsshpp.dir inside the ../libssh/build/examples/CMakeFiles folder. For the installation to succeed, you must also delete the corresponding lines of code in Makefile2 (inside ../libssh/build/CMakeFiles) that are responsible to compile these two example files. Open Makefile2 in your preferred texteditor and search for examples/CMakeFiles/libsshpp_noexcept.dir/build and examples/CMakeFiles/libsshpp.dir/build in the file. You now have to delete everything that checks and installs/compiles these two files/dirs. I deleted the following parts:

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

delete everything inside here

...

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

By deleting the content inside the seperators, you delete the installing/compilation procedure of the two (not necessary) example files provided by libssh.

Now run make install inside ../libssh/build and you should be good to go.

Upvotes: 1

Related Questions