|
Packit Service |
31306d |
# How to build from source
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
## Requirements
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
### Common requirements
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
In order to build libssh, you need to install several components:
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
- A C compiler
|
|
Packit Service |
31306d |
- [CMake](https://www.cmake.org) >= 2.6.0.
|
|
Packit Service |
31306d |
- [openssl](https://www.openssl.org) >= 0.9.8
|
|
Packit Service |
31306d |
or
|
|
Packit Service |
31306d |
- [gcrypt](https://www.gnu.org/directory/Security/libgcrypt.html) >= 1.4
|
|
Packit Service |
31306d |
- [libz](https://www.zlib.net) >= 1.2
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
optional:
|
|
Packit Service |
31306d |
- [cmocka](https://cmocka.org/) >= 1.1.0
|
|
Packit Service |
31306d |
- [socket_wrapper](https://cwrap.org/) >= 1.1.5
|
|
Packit Service |
31306d |
- [nss_wrapper](https://cwrap.org/) >= 1.1.2
|
|
Packit Service |
31306d |
- [uid_wrapper](https://cwrap.org/) >= 1.2.0
|
|
Packit Service |
31306d |
- [pam_wrapper](https://cwrap.org/) >= 1.0.1
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
Note that these version numbers are version we know works correctly. If you
|
|
Packit Service |
31306d |
build and run libssh successfully with an older version, please let us know.
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
For Windows use vcpkg:
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
https://github.com/Microsoft/vcpkg
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
which you can use to install openssl and zlib. libssh itself is also part of
|
|
Packit Service |
31306d |
vcpkg!
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
## Building
|
|
Packit Service |
31306d |
First, you need to configure the compilation, using CMake. Go inside the
|
|
Packit Service |
31306d |
`build` dir. Create it if it doesn't exist.
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
GNU/Linux, MacOS X, MSYS/MinGW:
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
cmake -DUNIT_TESTING=ON -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug ..
|
|
Packit Service |
31306d |
make
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
On Windows you should choose a makefile gernerator with -G or use
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
cmake-gui.exe ..
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
To enable additional client tests against a local OpenSSH server, add the
|
|
Packit Service |
31306d |
compile option -DCLIENT_TESTING=ON. These tests require an OpenSSH
|
|
Packit Service |
31306d |
server package and some wrapper libraries (see optional requirements) to
|
|
Packit Service |
31306d |
be installed.
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
If you're interested in server testing, then a OpenSSH client should be
|
|
Packit Service |
31306d |
installed on the system and if possible also dropbear. Once that is done
|
|
Packit Service |
31306d |
enable server support with -DWITH_SERVER=ON and enable testing of it with
|
|
Packit Service |
31306d |
-DSERVER_TESTING=ON.
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
## Testing build
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
make test
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
### CMake standard options
|
|
Packit Service |
31306d |
Here is a list of the most interesting options provided out of the box by
|
|
Packit Service |
31306d |
CMake.
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
- CMAKE_BUILD_TYPE: The type of build (can be Debug Release MinSizeRel
|
|
Packit Service |
31306d |
RelWithDebInfo)
|
|
Packit Service |
31306d |
- CMAKE_INSTALL_PREFIX: The prefix to use when running make install (Default
|
|
Packit Service |
31306d |
to /usr/local on GNU/Linux and MacOS X)
|
|
Packit Service |
31306d |
- CMAKE_C_COMPILER: The path to the C compiler
|
|
Packit Service |
31306d |
- CMAKE_CXX_COMPILER: The path to the C++ compiler
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
### CMake options defined for libssh
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
Options are defined in the following files:
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
- DefineOptions.cmake
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
They can be changed with the -D option:
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
`cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug -DWITH_ZLIB=OFF ..`
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
### Browsing/editing CMake options
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
In addition to passing options on the command line, you can browse and edit
|
|
Packit Service |
31306d |
CMake options using `cmakesetup` (Windows), `cmake-gui` or `ccmake` (GNU/Linux
|
|
Packit Service |
31306d |
and MacOS X).
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
- Go to the build dir
|
|
Packit Service |
31306d |
- On Windows: run `cmakesetup`
|
|
Packit Service |
31306d |
- On GNU/Linux and MacOS X: run `ccmake ..`
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
### Useful Windows options:
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
If you have installed OpenSSL or ZLIB in non standard directories, maybe you
|
|
Packit Service |
31306d |
want to set:
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
OPENSSL_ROOT_DIR
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
and
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
ZLIB_ROOT_DIR
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
## Installing
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
If you want to install libssh after compilation run:
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
make install
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
## Running
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
The libssh binary can be found in the `build/src` directory.
|
|
Packit Service |
31306d |
You can use `build/examples/samplessh` which is a sample client to
|
|
Packit Service |
31306d |
test libssh on UNIX.
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
## About this document
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
This document is written using [Markdown][] syntax, making it possible to
|
|
Packit Service |
31306d |
provide usable information in both plain text and HTML format. Whenever
|
|
Packit Service |
31306d |
modifying this document please use [Markdown][] syntax.
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
[markdown]: https://www.daringfireball.net/projects/markdown
|