MacOS
Here's how you can install Crow on your Mac.
Getting Crow¶
From a release¶
Archive¶
Crow provides an archive containing the framework and CMake files, You will only need the include
folder inside that archive.
Single header file¶
You can also download the crow_all.h
file which replaces the include
folder.
From Source¶
To get Crow from source, you only need to download the repository (as a .zip
or through git clone https://github.com/CrowCpp/Crow.git
).
include folder¶
Once you've downloaded Crow's source code, you only need to take the include
folder.
Single header file¶
You can generate your own single header file by navigating to the scripts
folder with your terminal and running the following command:
python3 merge_all.py ../include crow_all.h
crow_all.h
file which you can use in the following steps
Warning
crow_all.h
is recommended only for small, possibly single source file projects. For larger projects, it is advised to use the multi-header version.
Setting up your Crow project¶
Using XCode¶
- Download and install Homebrew.
- Run
brew install asio
in your terminal. - Create a new XCode project (macOS -> Command Line Tool).
-
Change the following project settings:
- Add header search paths for crow's include folder and asio's folder (
/usr/local/include
,/usr/local/Cellar/asio/include
, and where you placed Crow'sinclude
folder) - Add linker flags (
-lpthread
)
- Place
crow_all.h
inside your project folder and add it to the project in XCode (you need to use File -> Add files to "project_name") - Add header search paths for asio's folder:
/usr/local/include
, and- Silicon:
/opt/homebrew/Cellar/asio/<asio_version>/include
- Intel:
/usr/local/Cellar/asio/<asio_version>/include
- Add linker flags (
-lpthread
for g++,-pthread
for clang++)
- Add header search paths for crow's include folder and asio's folder (
-
Write your Crow application in
main.cpp
(something like the Hello World example will work). - Press
▶
to compile and run your Crow application.
Building Crow's tests/examples¶
Note
This tutorial can be used for Crow projects built with CMake as well
- Download and install Homebrew.
- Run
brew install cmake asio
in your terminal. - Get Crow's source code (the entire source code).
- Run the following Commands:
mkdir build
cd build
cmake ..
make -j12
Note
You can add options like `-DCROW_ENABLE_COMPRESSION=ON`
or `-DCROW_ENABLE_SSL=ON`
or `-DCROW_AMALGAMATE`
to `cmake ..` to build optional tests/examples for HTTP Compression or HTTPS.
Compiling using a compiler directly¶
All you need to do is run the following command:
g++ main.cpp -lpthread
Note
You'll need to install GCC via brew install gcc
. the Clang compiler should be part of XCode or XCode command line tools.
You can use arguments like -DCROW_ENABLE_DEBUG
, -DCROW_ENABLE_COMPRESSION -lz
for HTTP Compression, or -DCROW_ENABLE_SSL -lssl
for HTTPS support, or even replace g++ with clang++.
If GCC throws errors and your program does not compile, you may be using C++03 instead of ≥C++11. Use the flag -std=c++11
.