2021-09-29 22:43:50 +00:00
Here's how you can install Crow on your Mac.
2021-11-06 08:54:29 +00:00
## Getting Crow
### From a [release](https://github.com/CrowCpp/Crow/releases)
#### Archive
2021-09-29 22:43:50 +00:00
Crow provides an archive containing the framework and CMake files, You will only need the `include` folder inside that archive.
2021-11-06 08:54:29 +00:00
#### Single header file
2021-09-29 22:43:50 +00:00
You can also download the `crow_all.h` file which replaces the `include` folder.
2021-11-06 08:54:29 +00:00
### From Source
2021-09-29 22:43:50 +00:00
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` ).
2021-11-06 08:54:29 +00:00
#### include folder
2021-09-29 22:43:50 +00:00
Once you've downloaded Crow's source code, you only need to take the `include` folder.
2021-11-06 08:54:29 +00:00
#### 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:
2021-09-29 22:43:50 +00:00
```
python3 merge_all.py ../include crow_all.h
```
This will generate a `crow_all.h` file which you can use in the following steps
2022-03-23 22:55:46 +00:00
!!! warning
2021-09-29 22:43:50 +00:00
`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.
2021-11-06 08:54:29 +00:00
## Setting up your Crow project
### Using XCode
2021-09-29 22:43:50 +00:00
1. Download and install [Homebrew ](https://brew.sh ).
2. Run `brew install boost` in your terminal.
3. Create a new XCode project (macOS -> Command Line Tool).
4. Change the following project settings:
=== "Multiple Headers"
1. Add header search paths for crow's include folder and boost's folder (`/usr/local/include`, `/usr/local/Cellar/boost/include` , and where you placed Crow's `include` folder)
2. Add linker flags (`-lpthread` and `-lboost_system` if you're running an old version of boost)
=== "Single Header"
2021-11-06 08:54:29 +00:00
1. 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")
2021-09-29 22:43:50 +00:00
2. Add header search paths for boost's folder (`/usr/local/include`, and `/usr/local/Cellar/boost/include` )
3. Add linker flags (`-lpthread` and `-lboost_system` if you're running an old version of boost)
5. Write your Crow application in `main.cpp` (something like the Hello World example will work).
6. Press `▶` to compile and run your Crow application.
2021-11-06 08:54:29 +00:00
## Building Crow's tests/examples
2022-03-23 22:55:46 +00:00
!!! note
2021-12-03 03:38:14 +00:00
This tutorial can be used for Crow projects built with CMake as well
2021-09-29 22:43:50 +00:00
1. Download and install [Homebrew ](https://brew.sh ).
2. Run `brew install cmake boost` in your terminal.
3. Get Crow's source code (the entire source code).
3. Run the following Commands:
1. `mkdir build`
2. `cd build`
3. `cmake ..`
4. `make -j12`
2022-03-23 22:55:46 +00:00
!!! note
2021-09-29 22:43:50 +00:00
2022-03-23 22:55:46 +00:00
You can add options like `-DCROW_ENABLE_SSL` , `-DCROW_ENABLE_COMPRESSION` , or `-DCROW_AMALGAMATE` to `cmake ..` to build their tests/examples.
2021-12-03 03:38:14 +00:00
## Compiling using a compiler directly
All you need to do is run the following command:
```
g++ main.cpp -lpthread
```
2022-03-23 22:55:46 +00:00
!!! note
2021-12-03 03:38:14 +00:00
2022-03-23 22:55:46 +00:00
You'll need to install GCC via `brew install gcc` . the Clang compiler should be part of XCode or XCode command line tools.
2021-12-03 03:38:14 +00:00
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++.
2022-03-23 22:55:46 +00:00
!!! warning
2021-12-03 03:38:14 +00:00
If you're using a version of boost prior to 1.69, you'll need to add the argument `-lboost_system` in order for you Crow application to compile correctly.