switch asio from standalone to boost

This commit is contained in:
Chunting Gu
2020-08-31 14:57:47 +08:00
parent 20f02aa704
commit d49db1ec9c
507 changed files with 237 additions and 110294 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
## Dependencies
* [Asio](https://github.com/chriskohlhoff/asio) (already included in `third_party` folder)
* [Boost 1.66+](https://www.boost.org/) (asio, system, date_time)
* [OpenSSL](https://www.openssl.org/) (for HTTPS, optional)
* [Zlib](https://www.zlib.net/) (for GZIP compression, optional)
* [Googletest/gtest](https://github.com/google/googletest) (for automation and unit tests, optional)
+51 -2
View File
@@ -22,6 +22,55 @@ sudo apt install cmake
sudo apt install zlib1g-dev libssl-dev
```
## Install Boost
Download the `.tar.bz2` or `.tar.gz` from [here](https://www.boost.org/users/download/#live).
Unpack and go into the directory (suppose Boost version is 1.70):
```
tar -xzf boost_1_70_0.tar.bz2
cd boost_1_70_0
```
Run `bootstrap.sh` to generate `b2`:
```
./bootstrap.sh
```
You can change install prefix with `--prefix` (default is `/usr/local`, need `sudo`), but I don't recommend.
Build and install:
```
sudo ./b2 --with-system --with-date_time variant=debug link=static threading=multi -j4 install
```
Notes:
- Only build the specified libraries. `Asio` itself is header only so doesnt have to be built.
- Only build static libraries (`link=static`)
- The number after `-j` depends on the number of CPU cores you have.
- If you want to build release version libraries, set `variant=release`. The `debug` and `release` libraries have exactly the same name, so you cannot build them both at the same time.
- Dont forget the `sudo` since the install prefix is `/usr/local`.
To clean the build, run `b2` with target "clean":
```
./b2 clean
```
The libraries are installed to `/usr/local/lib`. E.g.,
```
$ ls -l /usr/local/lib/libboost*
-rw-r--r-- 1 adam admin 540288 Apr 21 11:01 /usr/local/lib/libboost_date_time.a
...
```
The headers are installed to `/usr/local/include/boost`.
## Build Webcc
Create a build folder under the root (or any other) directory, and `cd` to it:
@@ -39,7 +88,7 @@ cmake -G"Unix Makefiles" \
-DWEBCC_ENABLE_LOG=1 \
-DWEBCC_LOG_LEVEL=0 \
-DWEBCC_ENABLE_SSL=1 \
-DWEBCC_ENABLE_GZIP=1 \g
-DWEBCC_ENABLE_GZIP=1 \
-DWEBCC_ENABLE_AUTOTEST=OFF \
-DWEBCC_ENABLE_UNITTEST=OFF \
-DWEBCC_ENABLE_EXAMPLES=OFF \
@@ -66,7 +115,7 @@ Install the libraries:
make install
```
If you `WEBCC_ENABLE_AUTOTEST` was `ON`, you can run the automation test:
If `WEBCC_ENABLE_AUTOTEST` was `ON`, you can run the automation test:
```
cd autotest
+4 -5
View File
@@ -10,9 +10,9 @@ Download the .dmg from [here](https://cmake.org/download/). Just double click an
## Install Boost
Download the .tar.bz2 or .tar.gz from [here](https://www.boost.org/users/download/#live). The current version is 1.70.0.
Download the .tar.bz2 or .tar.gz from [here](https://www.boost.org/users/download/#live).
Unpack and go into the directory:
Unpack and go into the directory (suppose Boost version is 1.70):
```
tar -xzf boost_1_70_0.tar.bz2
@@ -30,7 +30,7 @@ You can change install prefix with `--prefix` option (default is `/usr/local`, n
Build and install:
```
sudo ./b2 --with-system --with-filesystem --with-date_time variant=debug link=static threading=multi -j4 install
sudo ./b2 --with-system --with-date_time variant=debug link=static threading=multi -j4 install
```
Notes:
@@ -52,7 +52,6 @@ The libraries are installed to `/usr/local/lib`. E.g.,
```
$ ls -l /usr/local/lib/libboost*
-rw-r--r-- 1 adam admin 540288 Apr 21 11:01 /usr/local/lib/libboost_date_time.a
-rw-r--r-- 1 adam admin 1717736 Apr 21 11:01 /usr/local/lib/libboost_filesystem.a
-rw-r--r-- 1 root admin 2976 Apr 21 11:01 /usr/local/lib/libboost_system.a
```
@@ -145,4 +144,4 @@ $ ./webcc_autotest
[----------] Global test environment tear-down
[==========] 7 tests from 1 test case ran. (13267 ms total)
[ PASSED ] 7 tests.
```
```
+32 -6
View File
@@ -1,14 +1,36 @@
# Build on Windows
I'm using [Visual Studio 2019 Community](https://visualstudio.microsoft.com/vs/community/), but I think 2017 should be OK, too.
I'm using [Visual Studio 2019 Community](https://visualstudio.microsoft.com/vs/community/), but I think VS2017 should be OK, too.
Webcc depends on `std::filesystem` which is a C++17 feature. There's a branch ([legacy](https://github.com/sprinfall/webcc/tree/legacy)) which is still using `boost::filesystem` so it could be built with VS2013. Check out it if you have only VS2013.
Webcc depends on `std::filesystem` which is a C++17 feature. There's a branch ([legacy](https://github.com/sprinfall/webcc/tree/legacy)) which is still using `boost::filesystem` so it could be built with even VS2013.
## Install Boost
Download the `.7z` or `.zip` from [here](https://www.boost.org/users/download/#live). Unpack it.
Open `x64 Native Tools Command Prompt for VS 2019` from Windows start menu (suppose you are only interested in a x64 build).
In the prompt, `cd` to the Boost root directory. Run `bootstrap.bat` to generate `b2.exe`:
Run `b2.exe` to start the build:
```
b2 --with-system --with-date_time variant=debug variant=release link=static threading=multi address-model=64 stage
```
NOTE: Given `address-model=64` `b2.exe` will not build any x86 libraries.
As you can see, we only need to build `system` and `date_time` which are used by Asio. Asio itself is a header-only library.
We don't install Boost to any other place (e.g., `C:\Boost`). We just `stage` it where it is.
In order for CMake to find Boost, please add an environment variable named `Boost_ROOT` pointing to the root directory of Boost.
## Install OpenSSL
Download from [here](http://slproweb.com/products/Win32OpenSSL.html).
The following installers (the "g" might change) are recommended for development:
The following installers (the suffix "g" might change according to revision) are recommended for development:
- Win64 OpenSSL v1.1.1g
- Win32 OpenSSL v1.1.1g
@@ -23,10 +45,12 @@ The only drawback of dynamic link is that you must distribute the OpenSSL DLLs t
## Install Zlib
Zlib has been included in `third_party\src`. Maybe it's not a good idea.
Zlib has been included in `third_party\src`.
In order to integrate `webcc` into your project, you have to integrate this zlib, too. This makes it complicated. I will come back to this later.
*TODO: Use CMake `find_package()` instead.*
## Install Googletest
Download the latest release of [Googletest](https://github.com/google/googletest/releases).
@@ -37,7 +61,7 @@ Use CMake to generate VS solution:
Please note the highlighted configurations.
The `CMAKE_INSTALL_PREFIX` has been changed to `D:/lib/cmake_install_2019_64` (NOTE: use "/" instead of "\\" as path seperators!). This path should be added to an environment variable named `CMAKE_PREFIX_PATH`. Then, CMake can find this installed Googletest during the configuration of Webcc.
The `CMAKE_INSTALL_PREFIX` has been changed to `D:/lib/cmake_install_2019_64` (NOTE: please use "/" instead of "\\" as path seperators!). This path should be added to an environment variable named `CMAKE_PREFIX_PATH`. Then, CMake can find this installed Googletest during the configuration of Webcc.
![CMAKE_PREFIX_PATH](screenshots/win_cmake_prefix_path.png)
@@ -49,7 +73,7 @@ Open CMake, set **Where is the source code** to Webcc root directory (e.g., `D:/
Check _**Grouped**_ and _**Advanced**_ two check boxes.
Click _**Configure**_ button, select the generator and platform (win32 or x64) from the popup dialog.
Click _**Configure**_ button, select the generator and platform (`win32` or `x64`) from the popup dialog.
![CMake generator](screenshots/win_cmake_generator.png)
@@ -64,3 +88,5 @@ Click _**Configure**_ button again. OpenSSL should be found.
Click _**Configure**_ button again. If everything is OK, click _**Generate**_ button to generate the VS solution.
Click _**Open Project**_ button to open VS.
Enjoy the build!