Blame INSTALL

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