Skip to content

Commit

Permalink
update for CROSS_COMPILE
Browse files Browse the repository at this point in the history
  • Loading branch information
ithewei committed Nov 22, 2020
1 parent 23804f3 commit 3fc5d78
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 34 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ tmp
dist
test
build
hconfig.h
html/uploads

# msvc
Expand Down
68 changes: 50 additions & 18 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,76 @@
- c99
- c++11

gcc4.8+, msvc2015+
gcc4.8+, msvc2015 or later

## Dependencies
modify config.mk

## Unix
## Makefile
options modify config.mk
```
./configure
make
sudo make install
```

## cmake
options modify CMakeLists.txt
```
mkdir build
cd build
cmake ..
cmake --build .
```

## Unix
use Makefile or cmake

## Windows
use cmake
```
mkdir win64
cd win64
cmake .. -G "Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE=Release
cmake --build .
```

## CROSS_COMPILE
use Makefile
```
export CROSS_COMPILE=arm-linux-androideabi-
sudo apt install gcc-arm-linux-gnueabi g++-arm-linux-gnueabi # ubuntu
export CROSS_COMPILE=arm-linux-gnueabi-
./configure
make
make clean
make libhv
```
or use cmake
```
mkdir build
cd build
cmake .. -DCMAKE_C_COMPILER=arm-linux-gnueabi-gcc -DCMAKE_CXX_COMPILER=arm-linux-gnueabi-g++
cmake --build . --target libhv libhv_static
```

### mingw
see CROSS_COMPILE

For example:
```
sudo apt-get install mingw-w64 # ubuntu
sudo apt install mingw-w64 # ubuntu
#export CROSS_COMPILE=i686-w64-mingw32-
export CROSS_COMPILE=x86_64-w64-mingw32-
./configure
make
make clean
make libhv
```

## cmake
### android
see CROSS_COMPILE
```
mkdir build
cd build
cmake ..
#https://developer.android.com/ndk/downloads
#export NDK_ROOT=~/Downloads/android-ndk-r21b
#sudo $NDK_ROOT/build/tools/make-standalone-toolchain.sh --arch=arm --platform=android-21 --install-dir=/opt/ndk/arm
#sudo $NDK_ROOT/build/tools/make-standalone-toolchain.sh --arch=arm64 --platform=android-21 --install-dir=/opt/ndk/arm64
#export PATH=/opt/ndk/arm/bin:/opt/ndk/arm64/bin:$PATH
#export CROSS_COMPILE=arm-linux-androideabi-
export CROSS_COMPILE=aarch64-linux-android-
./configure
make clean
make libhv
make libhv_static
make unittest
make examples
```
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ bin/nc 127.0.0.1 10514
```

## BUILD
see BUILD.md

### lib
- make libhv
Expand Down Expand Up @@ -201,21 +202,23 @@ https is the best example.
```
sudo apt install openssl libssl-dev # ubuntu
make clean
make libhv httpd curl WITH_OPENSSL=yes
make WITH_OPENSSL=yes
# editor etc/httpd.conf => ssl = on
bin/httpd -d
bin/httpd -s restart -d
bin/curl -v https://localhost:8080
curl -v https://localhost:8080 --insecure
```

#### compile WITH_CURL
- make WITH_CURL=yes DEFINES="CURL_STATICLIB"
```
make WITH_CURL=yes DEFINES="CURL_STATICLIB"
```

#### compile WITH_NGHTTP2
```
sudo apt install libnghttp2-dev # ubuntu
make clean
make libhv httpd curl WITH_NGHTTP2=yes
make WITH_NGHTTP2=yes
bin/httpd -d
bin/curl -v localhost:8080 --http2
```
Expand All @@ -225,9 +228,6 @@ see config.mk

### echo-servers
```shell
# ubuntu16.04
sudo apt install libevent-dev libev-dev libuv1-dev libboost-dev libboost-system-dev libasio-dev libpoco-dev
# muduo install => https://github.com/chenshuo/muduo.git
cd echo-servers
./build.sh
./benchmark.sh
Expand Down
2 changes: 1 addition & 1 deletion config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ENABLE_IPV6=no
ENABLE_UDS=no
# base/RAII.cpp: Windows MiniDumpWriteDump
ENABLE_WINDUMP=no
# http/http_content.h: QueryParams,MultiPart
# http/http_content.h: KeyValue,QueryParams,MultiPart
USE_MULTIMAP=no

# dependencies
Expand Down
2 changes: 1 addition & 1 deletion http/server/http_page.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void make_index_of_page(const char* dir, std::string& page, const char* url) {
else {
float hsize;
if (item.size < 1024) {
snprintf(c_str, sizeof(c_str), "%lu", item.size);
snprintf(c_str, sizeof(c_str), "%lu", (unsigned long)item.size);
}
else if ((hsize = item.size/1024.0f) < 1024.0f) {
snprintf(c_str, sizeof(c_str), "%.1fK", hsize);
Expand Down
14 changes: 7 additions & 7 deletions readme_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ bin/nc 127.0.0.1 10514
```

## 构建
见BUILD.md

###
- make libhv
Expand Down Expand Up @@ -199,21 +200,23 @@ https就是做好的例子:
```
sudo apt install openssl libssl-dev # ubuntu
make clean
make libhv httpd curl WITH_OPENSSL=yes
make WITH_OPENSSL=yes
# editor etc/httpd.conf => ssl = on
bin/httpd -d
bin/httpd -s restart -d
bin/curl -v https://localhost:8080
curl -v https://localhost:8080 --insecure
```

#### 编译WITH_CURL
- make WITH_CURL=yes DEFINES="CURL_STATICLIB"
```
make WITH_CURL=yes DEFINES="CURL_STATICLIB"
```

#### 编译WITH_NGHTTP2
```
sudo apt install libnghttp2-dev # ubuntu
make clean
make libhv httpd curl WITH_NGHTTP2=yes
make WITH_NGHTTP2=yes
bin/httpd -d
bin/curl -v localhost:8080 --http2
```
Expand All @@ -223,9 +226,6 @@ bin/curl -v localhost:8080 --http2

### echo-servers
```shell
# ubuntu16.04
sudo apt install libevent-dev libev-dev libuv1-dev libboost-dev libboost-system-dev libasio-dev libpoco-dev
# muduo install => https://github.com/chenshuo/muduo.git
cd echo-servers
./build.sh
./benchmark.sh
Expand Down

0 comments on commit 3fc5d78

Please sign in to comment.