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