1 # Building and installing Libevent
5 - [Prerequisites](#Prerequisites)
6 - [Autoconf](#autoconf)
7 - [Flags](#autoconf-flags)
8 - [Building on Windows](#building-on-windows)
9 - [Building on Unix (With CMake)](#building-on-unix-cmake)
10 - [CMake Variables](#cmake-variables)
14 ### Linux deb-like (ubuntu/debian/...)
16 Just install tools using your preferred package manager if you build using autotools:
19 sudo apt-get install automake autoconf libtool pkg-config
25 sudo apt-get install cmake
28 Doxygen is a tool for generating documentation. Git is used to fetch the package version.
29 Install them if needed:
32 sudo apt-get install doxygen git
35 libevent has encryption layer, you need openssl or mbedTLS for it, you can
36 install one of this using:
39 sudo apt-get install libssl-dev libmbedtls-dev
42 To support multithreaded environments, libpthread is a must, and it already exists in the system.
44 To run the tests, you should install zlib:
47 sudo apt-get install zlib1g-dev
50 Finally, python interpreter should be installed if you want to run regression tests.
54 On MacOS you can use `brew` to manage packages.
56 The installation process on MacOS is roughly the same as on Linux,
57 the difference is installation of openssl and zlib:
60 brew install openssl zlib
65 To install it, there are two choices: installer and zip file.
67 If using zip file, you should set the PATH variable in the Environment
68 Variables for your User to include the installation path of cmake.
70 Install Visual Studio which is the true compiler that will be used.
72 Install OpenSSL to support for encryption, then add the installation path into the PATH variable in the Environment Variables,
73 or set OPENSSL_ROOT_DIR in command prompt:
76 set "OPENSSL_ROOT_DIR=C:\path\to\OpenSSL"
79 or add `OPENSSL_ROOT_DIR` definition to the cmake command:
82 cmake -DOPENSSL_ROOT_DIR=C:/path/to/OpenSSL ...
92 **Note: If you had downloaded libevent from the Git repository, then you have to run `./autogen.sh` first!**
94 You can run the regression tests by running
98 *Before reporting any problems, please run the regression tests.*
105 To enable low-level tracing, build the library as:
107 $ CFLAGS=-DUSE_DEBUG ./configure [...]
112 Standard configure flags should work. In particular, see:
114 --disable-shared Only build static libraries.
115 --prefix Install all files relative to this directory.
118 The configure script also supports the following flags:
120 --enable-gcc-warnings Enable extra compiler checking with GCC.
121 --disable-malloc-replacement
122 Don't let applications replace our memory
123 management functions.
124 --disable-openssl Disable support for OpenSSL encryption.
125 --disable-thread-support Don't support multithreaded environments.
126 --enable-doxygen-doc Build doxygen documentation
129 ## Building on Windows
130 __Download CMake for Windows [here](https://cmake.org/download/)__
132 > md build && cd build
133 > cmake -G "Visual Studio 10" .. # Or use any generator you want to use. Run cmake --help for a list
134 > cmake --build . --config Release # Or "start libevent.sln" and build with menu in Visual Studio.
136 In the above, the ".." refers to the dir containing the Libevent source code. You can build multiple versions (with different compile time settings) from the same source tree by creating other build directories.
138 It is highly recommended to build "out of source" when using CMake instead of "in source" like the normal behaviour of autoconf for this reason.
140 The "NMake Makefiles" CMake generator can be used to build entirely via the command line:
145 ## Building on Unix (CMake)
146 __Install Cmake with your distribution's package manager `apt-get`/`dnf`/etc__
148 $ mkdir build && cd build
149 $ cmake .. # Default to Unix Makefiles
151 $ make verify # Optional
157 # Type of the library to build (SHARED or STATIC)
158 # Default is: SHARED for MSVC, otherwise BOTH
159 EVENT__LIBRARY_TYPE:STRING=DEFAULT
161 # Installation directory for CMake files
162 EVENT_INSTALL_CMAKE_DIR:PATH=lib/cmake/libevent
164 # Enable running gcov to get a test coverage report (only works with
165 # GCC/CLang). Make sure to enable -DCMAKE_BUILD_TYPE=Debug as well.
166 EVENT__COVERAGE:BOOL=OFF
168 # Defines if Libevent should build without the benchmark executables
169 EVENT__DISABLE_BENCHMARK:BOOL=OFF
171 # Define if Libevent should build without support for a debug mode
172 EVENT__DISABLE_DEBUG_MODE:BOOL=OFF
174 # Define if Libevent should not allow replacing the mm functions
175 EVENT__DISABLE_MM_REPLACEMENT:BOOL=OFF
177 # Define if Libevent should build without support for OpenSSL encryption
178 EVENT__DISABLE_OPENSSL:BOOL=OFF
180 # Disable the regress tests
181 EVENT__DISABLE_REGRESS:BOOL=OFF
183 # Disable sample files
184 EVENT__DISABLE_SAMPLES:BOOL=OFF
186 # If tests should be compiled or not
187 EVENT__DISABLE_TESTS:BOOL=OFF
189 # Define if Libevent should not be compiled with thread support
190 EVENT__DISABLE_THREAD_SUPPORT:BOOL=OFF
192 # Enables verbose debugging
193 EVENT__ENABLE_VERBOSE_DEBUG:BOOL=OFF
195 # When cross compiling, forces running a test program that verifies that Kqueue
196 # works with pipes. Note that this requires you to manually run the test program
197 # on the the cross compilation target to verify that it works. See CMake
198 # documentation for try_run for more details
199 EVENT__FORCE_KQUEUE_CHECK:BOOL=OFF
201 # Build documentation with doxygen
202 EVENT__DOXYGEN:BOOL=OFF
204 MSVC specific options:
206 # Link static runtime libraries.
207 # Defaults to ON if EVENT_LIBRARY_TYPE is equal to "STATIC", otherwise OFF
208 EVENT__MSVC_STATIC_RUNTIME:BOOL
210 GNUC specific options:
212 # Disable verbose warnings with GCC
213 EVENT__DISABLE_GCC_WARNINGS:BOOL=OFF
215 # Enable compiler security checks
216 EVENT__ENABLE_GCC_HARDENING:BOOL=OFF
218 # Enable gcc function sections
219 EVENT__ENABLE_GCC_FUNCTION_SECTIONS:BOOL=OFF
221 # Make all GCC warnings into errors
222 EVENT__ENABLE_GCC_WARNINGS:BOOL=OFF
224 __More variables can be found by running `cmake -LAH <sourcedir_path>`__
226 [Back to top ↑](#jump-to)