Setup
This page explains how to set Crow up for use with your project.
Requirements
- C++ compiler with C++14 support.
- Crow's CI uses g++-9.3 and clang-7.0 running on AMD64 (x86_64) and ARM64v8
- boost library (1.70 or later).
- (optional) ZLib for HTTP Compression.
- (optional) CMake and Python3 to build tests and/or examples.
- (optional) Linking with jemalloc/tcmalloc is recommended for speed.
Note
While using Boost 1.70 or later is recommended, it may be possible to compile a Crow application with version 1.64
Installing Requirements
Note
The Linux requirements are for developing and compiling a Crow application. Running a built application requires the actual libraries rather than just the development headers.
Ubuntu
sudo apt-get install build-essential libboost-all-dev
Non Debian based GNU/Linux
Use your package manager to install the following: - GCC and G++ (or Clang and Clang++) - Boost Development headers (sometimes part of the Boost package itself)
OSX
brew install boost
Windows
Microsoft Visual Studio 2019 (older versions not tested)
Downloading
Either run git clone https://github.com/crowcpp/crow.git or download crow_all.h from the releases section. You can also download a zip of the project on github.
Includes folder
- Copy the
/includesfolder to your project's root folder. - Add
#include "path/to/includes/crow.h"to your.cppfile. - For any middlewares, add
#include "path/to/includes/middlewares/some_middleware.h".
Single header file
If you've downloaded crow_all.h, you can skip to step 4.
- Make sure you have python 3 installed.
- Open a terminal (or
cmd.exe) instance in/path/to/crow/scripts. - Run
python merge_all.py ../include crow_all.h(replace/with\if you're on Windows). - Copy the
crow_all.hfile to where you put your libraries (if you don't know where this is, you can put it anywhere). - Add
#include "path/to/crow_all.h"to your.cppfile.
Note: All middlewares are included with the merged header file, if you would like to include or exclude middlewares use the-eor-iarguments.
building via CLI
To build a crow Project, do the following:
GCC (G++)
- Release:
g++ main.cpp -lpthread -lboost_system. - Debug:
g++ main.cpp -ggdb -lpthread -lboost_system -DCROW_ENABLE_DEBUG. - SSL:
g++ main.cpp -lssl -lcrypto -lpthread -lboost_system -DCROW_ENABLE_SSL.
Clang
- Release:
clang++ main.cpp -lpthread -lboost_system. - Debug:
clang++ main.cpp -g -lpthread -lboost_system -DCROW_ENABLE_DEBUG. - SSL:
clang++ main.cpp -lssl -lcrypto -lpthread -lboost_system -DCROW_ENABLE_SSL.
Microsoft Visual Studio 2019
The following guide will use example_with_all.cpp as the Crow application for demonstration purposes.
- Generate
crow_all.hfollowing Single header file. git clone https://github.com/microsoft/vcpkg.git.\vcpkg\bootstrap-vcpkg.bat.\vcpkg\vcpkg integrate install- Create empty Visual Studio project.
- In solution explorer, right click the name of your project then click
Open Folder in File Explorer. - Copy
crow_all.h,example_with_all.cpp,vcpkg.jsonto opened folder. - Add
crow_all.htoHeader Filesandexample_with_all.cpptoSource Files. - In solution explorer, right click the name of your project then click
Properties. - Under
vcpkg, setUse Vcpkg ManifesttoYesandAdditional Optionsto--feature-flags="versions". - Set
Debug/Releaseandx64/x86. - Run.
building via CMake
Add the following to your CMakeLists.txt:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | |
Note
The last 2 lines are unnecessary if you're using crow_all.h.
Building Crow tests and examples
Out-of-source build with CMake is recommended.
mkdir build
cd build
cmake ..
make
crow_all.h file and place it in the build directory.You can run tests with following command:
ctest -V
Installing Crow
if you wish to use Crow globally without copying crow_all.h in your projects, you can install Crow on your machine with the procedure below.
mkdir build
cd build
cmake ..
make install
make install will copy crow_all.h automatically in your /usr/local/include thus making it available globally for use.