1

I'm writing a C++ program using libssh so I look around to install the library. At first I install by sudo apt-get install libssh-dev but there's no libsshpp.hpp in /usr/include/libssh.

Then I clone git://git.libssh.org/projects/libssh.git libssh in ~ directory and run ./build/build_make.sh, it has libsshpp.hpp in ~/libssh/include but not in /usr/include/libssh.

I think it's because different version between them, the newer have libsshpp.hpp, I then try to copy file libsshpp.hpp to /usr/include/libssh but there's many error when I compile example libsshpp.cpp in examples folder so I think this is not solution.

My question is how can I install newest version of libssh and automatically add headers to /usr/include/libssh not only in its own install folder?

Nhan Ly
  • 95
  • 1
  • 4
  • 12

3 Answers3

1

If you really want to do that, you can modify include/libssh/CMakeLists.txt and add

libsshpp.hpp

to the libssh_HDRS variable. Because it's not installed by default, this may be not supported officially.

Henry Hu
  • 524
  • 4
  • 12
  • Please open a bug at https://red.libssh.org/ that we install the header file in future! Thanks. – asn Apr 04 '14 at 11:18
0

You are probably better off not using the code from the git repository for the reason that those headers won't match the code for libssh that's actually installed on your system.

So I'd recommend reversing the changes you made (delete the files or symlinks you copied or created) and instead installing the development parts using apt. You can find out which header files were installed by doing this:

rpm -ql libssh-dev

On my system (Fedora) the package is actually called libssh-devel. When I run

rpm -ql libssh-devel

I get the following output (partial)

/usr/include/libssh/callbacks.h
/usr/include/libssh/legacy.h
/usr/include/libssh/libssh.h
/usr/include/libssh/server.h
/usr/include/libssh/sftp.h
/usr/include/libssh/ssh2.h
/usr/lib64/cmake/libssh-config-version.cmake
/usr/lib64/cmake/libssh-config.cmake
/usr/lib64/libssh.so
/usr/lib64/libssh_threads.so
    ...

As you can see, the libssh.h header is in the libssh directory, so from your code you'd use

#include <libssh/libssh.h>

Using that method will better assure that the headers you have installed will match the libraries you have installed and save many frustrating hours later.

Here's a quick test program you can use to make sure it's really working:

// sshtest.cpp
#include <iostream>
#include <libssh/libssh.h>

int main()
{
    std::cout << ssh_copyright() << std::endl;
    return 0;
}

Compile, link and run:

g++ -o sshtest sshtest.cpp -lssh ./sshtest

This should produce the copyright string which starts with the libssh version number so you can verify that it matches the version you expected.

On my machine just now, that produced the following output:

0.6.3 (c) 2003-2014 Aris Adamantiadis, Andreas Schneider, and libssh contributors. Distributed under the LGPL, please refer to COPYING file for information about your rights

Good luck.

Edward
  • 6,964
  • 2
  • 29
  • 55
0

On Ubuntu you can install the library with

apt-get install libssh-dev

Then, if you're compiling manually use -lssh to link the library eg.

gcc -lssh ssh-program.c
jx12345
  • 1,650
  • 2
  • 22
  • 40