(Not OK) 在CentOS7—編譯nginx—for—Android
NGINX VERSION: nginx-1.9.7
ZLIB VERSION: zlib-1.2.8
PCRE VERSION: pcre-8.37
[[email protected] nginx-on-android]# pwd
/opt/cBPM-android/nginx-on-android
[[email protected] nginx-on-android]# ls
nginx-1.9.7 nginx_mod_h264_streaming-2.2.7 nginx-rtmp-module openssl-1.0.1p pcre-8.37 zlib-1.2.8
++++++++++++++++++++++++++++++++++++++++
參考:http://m.blog.csdn.net/blog/zangcf/22688873
前面做過很多次嘗試,編譯也通過了,但是去掉了很多glob和crypto的函式,導致執行的時候還是會出錯,所以,本次按照正常方法,加全所有的函式,然後編譯之後執行。
1)在工作目錄下建立build目錄
/opt/cBPM-android/nginx-on-android/build
2)準備檔案,
a) 下載openssl,wget wget http://www.openssl.org/source/openssl-1.0.1p.tar.gz
b) 下載nginx,wget http://nginx.org/download/nginx-1.9.7.tar.gz
c) 下載pcre,wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.37.tar.gz
d) 下載zlib,wget http://www.zlib.net/zlib-1.2.8.tar.gz
e) 下載下載nginx_mod_h264,wget http://h264.code-shop.com/download/nginx_mod_h264_streaming-2.2.7.tar.gz
f) 下載rtmp模組,git clone https://github.com/arut/nginx-rtmp-module
3) 編譯openssl
a) tar tar xvf openssl-1.0.1p.tar.gz
b) cd openssl-1.0.1p
c) 使用如下的配置檔案
--------------------------------my_configure_openssl.sh start here-----------------------------------------
#!/bin/sh
./config no-asm shared \
--prefix=/opt/cBPM-android/nginx-on-android/build \
--------------------------------my_configure_openssl.sh end here-----------------------------------------
d) gedit Makefile,進入修改Makefile
1 step) 找到所有的-m64,刪除
2 step) 找到CC= gcc,替換為CC= /opt/android-on-linux/android-ndk-r8e/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc
3 step) 找到AR= ar $(ARFLAGS) r,替換為AR= /opt/android-on-linux/android-ndk-r8e/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ar $(ARFLAGS) r
4 step) 找到RANLIB= /usr/bin/ranlib,替換為RANLIB= /opt/android-on-linux/android-ndk-r8e/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ranlib
5 step) 找到NM= nm,修改為NM= /opt/android-on-linux/android-ndk-r8e/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc-nm
6 step) 找到MAKEDEPPROG= gcc,修改為MAKEDEPPROG= /opt/android-on-linux/android-ndk-r8e/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc
e)cp Makefile Makefile.ok
f)執行make -j4 && make install
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
或者 使用下面方法:
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
參考: https://wiki.openssl.org/index.php/Android
下載makedepend.zip , 從http://llg.cubic.org/docs/vc7.html下載。 解壓編譯,然後 cp makedepend /bin/
下載Setenv-android.sh , wget https://wiki.openssl.org/images/7/70/Setenv-android.sh
[
#-------------------------------------------------------
ANDROID_NDK_ROOT="/opt/android-on-linux/android-ndk-r8e"
_ANDROID_NDK="android-ndk-r8e"
_ANDROID_EABI="arm-linux-androideabi-4.7"
_ANDROID_API="android-14"
export MACHINE=armv7
export RELEASE=2.6.37
export SYSTEM=android
export ARCH=arm
#export CROSS_COMPILE="arm-linux-androideabi-"
export CROSS_COMPILE=""
#-------------------------------------------------------
[
/opt/cBPM-android/nginx-on-android/openssl-1.0.1p
chmod a+x Setenv-android.sh
perl -pi -e 's/install: all install_docs install_sw/install: install_docs install_sw/g' Makefile.org
./config shared no-ssl2 no-ssl3 no-comp no-hw no-engine --openssldir=/usr/local/ssl/android-14/
make depend
make all
find . -name "*.a"
find . -name libcrypto.a
find . -name libssl.a
readelf -h ./libcrypto.a | grep -i 'class\|machine' | head -2
cp libssl.a libcrypto.a /opt/cBPM-android/criteria-lin/lib
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4) 編譯pcre
a)tar xvf pcre-8.37.tar.gz
b) cd pcre-8.37
c) gedit my_configure_pcre.sh
-------------------------my_configure_pcre.sh start here--------------------------
#!/bin/sh
NDK_ROOT="/opt/android-on-linux/android-ndk-r8e"
CPATH="/opt/android-on-linux/android-ndk-r8e/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/bin"
./configure \
--host=arm-linux \
--prefix=/opt/cBPM-android/nginx-on-android/build \
CPP="$CPATH/arm-linux-androideabi-cpp" \
CXX="$CPATH/arm-linux-androideabi-g++" \
CXXCPP="$CPATH/arm-linux-androideabi-cpp" \
CC="$CPATH/arm-linux-androideabi-gcc" \
AR="$CPATH/arm-linux-androideabi-ar" \
AS="$CPATH/arm-linux-androideabi-as"
-------------------------my_configure_pcre.sh end here-------------------------
d) chmod +x my_configure_pcre.sh
e)./my_configure_pcre.sh
f) make -j4 && make install
[
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
或者 使用(參考)下面方法:
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#!/bin/sh
NDK_ROOT="/opt/android-on-linux/android-ndk-r8e"
LDFLAGS="-L$NDK_ROOT/sources/cxx-stl/stlport/libs/armeabi-v7a -L/opt/cBPM-android/criteria-lin/lib -L/opt/cBPM-android/lighttpd-1.4.37/src/.libs -lstlport_static -lgcc -lc"
CPATH="$NDK_ROOT/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/bin"
CPP="$CPATH/arm-linux-androideabi-cpp"
CXX="$CPATH/arm-linux-androideabi-g++"
CXXCPP="$CPATH/arm-linux-androideabi-cpp"
CC="$CPATH/arm-linux-androideabi-gcc"
LD="$CPATH/arm-linux-androideabi-ld"
AR="$CPATH/arm-linux-androideabi-ar"
AS="$CPATH/arm-linux-androideabi-as"
./configure --host=arm-linux --prefix=/opt/cBPM-android/nginx-on-android/build CC=$CC CPP=$CPP AR=$AR AS=$AS CXX=$CXX CXXCPP=$CXXCPP
d) chmod u+x my_configure_pcre.sh
e) ./my_configure_pcre.sh
f) make && make install
++++++++++++++++
編譯pcre,也可以參考:http://blog.chinaunix.net/uid-14735472-id-5214130.html
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5) 解壓zlib
/opt/cBPM-android/nginx-on-android/zlib-1.2.8
6) 解壓nginx_mod_h264
/opt/cBPM-android/nginx-on-android/nginx_mod_h264_streaming-2.2.7
7) 編譯nginx
a) tar xvf nginx-1.9.7.tar.gz
b) cd nginx-1.9.7
c) gedit auto/cc/name
if [ "$NGX_PLATFORM" != win32 ]; then
ngx_feature="C compiler"
ngx_feature_name=
#ngx_feature_run=yes
ngx_feature_run=no ==>set to no to skip check
ngx_feature_incs=
ngx_feature_path=
#exit 1
d) gedit auto/types/sizeof
ngx_test="$CC $CC_TEST_FLAGS $CC_AUX_FLAGS
==> ngx_test="gcc $CC_TEST_FLAGS $CC_AUX_FLAGS
e) gedit src/os/unix/ngx_errno.h
at line 15 add #define NGX_SYS_NERR 333
f) gedit src/os/unix/ngx_shmem.c
#if (NGX_HAVE_MAP_ANON) ==> #if (!NGX_HAVE_MAP_ANON)
g) gedit auto/lib/pcre/make
./configure --disable-shared $PCRE_CONF_OPT
修改為
./configure --disable-shared $PCRE_CONF_OPT \
--host=arm-linux \
--prefix=/opt/cBPM-android/nginx-on-android/build \
CC=/opt/android-on-linux/android-ndk-r8e/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc \
CPP=/opt/android-on-linux/android-ndk-r8e/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/bin/arm-linux-androideabi-cpp \
AR=/opt/android-on-linux/android-ndk-r8e/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ar \
AS=/opt/android-on-linux/android-ndk-r8e/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/bin/arm-linux-androideabi-as \
CXX=/opt/android-on-linux/android-ndk-r8e/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++ \
CXXCPP=/opt/android-on-linux/android-ndk-r8e/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/bin/arm-linux-androideabi-cpp
h) gedit auto/lib/openssl/make
$OPENSSL/.openssl/include/openssl/ssl.h: $NGX_MAKEFILE
cd $OPENSSL \\
&& if [ -f Makefile ]; then \$(MAKE) clean; fi \\
&& ./config --prefix=$ngx_prefix no-shared $OPENSSL_OPT \\
&& \$(MAKE) \\
&& \$(MAKE) install LIBDIR=lib
修改為
$OPENSSL/.openssl/include/openssl/ssl.h: $NGX_MAKEFILE
cd $OPENSSL \\
i) 開啟/opt/cBPM-android/nginx-on-android/nginx_mod_h264_streaming-2.2.7/src/ngx_http_streaming_module.c,刪除
if (r->zero_in_uri) {
return NGX_DECLINED;
}
j) gedit my_configure_nginx.sh
------------------------my_configure_nginx.sh start here------------------------
#!/bin/sh
BUILD_PATH=/opt/cBPM-android/nginx-on-android/build
CC_PATH=/opt/android-on-linux/android-ndk-r8e/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc
CPP_PATH=/opt/android-on-linux/android-ndk-r8e/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++
LD_PATH=/opt/android-on-linux/android-ndk-r8e/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld
./configure \
--prefix=$BUILD_PATH \
--builddir=$BUILD_PATH \
--with-zlib=/opt/cBPM-android/nginx-on-android/zlib-1.2.8 \
--with-pcre=/opt/cBPM-android/nginx-on-android/pcre-8.37 \
--with-pcre-jit \
--with-cc=$CC_PATH \
--with-cpp=$CPP_PATH \
--with-ld-opt=$LD_PATH \
--with-openssl=/opt/cBPM-android/nginx-on-android/openssl-1.0.1p \
--add-module=/opt/cBPM-android/nginx-on-android/nginx_mod_h264_streaming-2.2.7 \
--with-http_flv_module \
--with-http_mp4_module \
--add-module=/opt/cBPM-android/nginx-on-android/nginx-rtmp-module
------------------------my_configure_nginx.sh end here------------------------
[[email protected] nginx-1.9.7]# ./my_configure_nginx.sh
k) gedit ../build/Makefile
注意這裡使用的arm_linux_gcc版本必須是4.4.3以後的,之前的本本可能會出錯。
1 step)找到 /opt/cBPM-android/nginx-on-android/openssl-1.0.1p/.openssl/include/openssl/ssl.h \,替換為/opt/cBPM-android/nginx-on-android/build/include/openssl/ssl.h
2 step)找到-I /opt/cBPM-android/nginx-on-android/openssl-1.0.1p/.openssl/include \,替換為-I /opt/cBPM-android/nginx-on-android/build/include/openssl \
3 step) CFLAGS增加-I/opt/cBPM-android/nginx-on-android/build/include
-I/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi/sys-root/usr/include和
4 step) CLAGS去掉 -Werror
5 step) 找到 /opt/cBPM-android/nginx-on-android/pcre-8.37/.libs/libpcre.a
/opt/cBPM-android/nginx-on-android/openssl-1.0.1p/.openssl/lib/libssl.a,
/opt/cBPM-android/nginx-on-android/openssl-1.0.1p/.openssl/lib/libcrypto.a
/opt/cBPM-android/nginx-on-android/pcre-8.37/.libs/libpcre.a
替換為/opt/cBPM-android/nginx-on-android/build/lib/*.a (上面四個檔案的路徑,位於同一個資料夾)
6 step) 在連結目標檔案增加libc的標準庫地址/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi/sys-root/usr/lib/libcrypt.a和/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi/sys-root/usr/lib/libc.a /opt/cBPM-android/nginx-on-android/build/lib/libpcre.a
這裡如果整合Makefile還有找不到的檔案,需要指定連結過程,類似做法如上。
l) make -j4 && make install
大工告成
---------------------------
$linker $libdirs -o $exe_output /opt/android-on-linux/android-ndk-r8e/platforms/android-14/arch-arm/usr/lib/crtbegin_static.o $link_objects $link_resobjects $link_options $libs /opt/android-on-linux/android-ndk-r8e/platforms/android-14/arch-arm/usr/lib/crtend_android.o
---------------------------
錯誤:
src/os/unix/ngx_linux_config.h:32:18: fatal error: glob.h: No such file or directory
解決:
參考:https://groups.google.com/forum/#!topic/Android-ndk/vSH6MWPD0Vk
[[email protected] nginx-1.9.7]# wget https://github.com/white-gecko/TokyoCabinet/raw/master/glob.h
[[email protected] nginx-1.9.7]# wget https://github.com/white-gecko/TokyoCabinet/raw/master/glob.c
[[email protected] nginx-1.9.7]# cp glob.* /opt/cBPM-android/nginx-on-android/build/
---------------------------
[[email protected] nginx-1.9.7]# gedit src/core/ngx_rwlock.c
#error ngx_atomic_cmp_set() is not defined!
改為:
//#error ngx_atomic_cmp_set() is not defined!
---------------------------
[[email protected] nginx-1.9.7]# gedit /opt/cBPM-android/nginx-on-android/zlib-1.2.8/contrib/minizip/crypt.h
新增:
#include "zconf.h"
---------------------------
[[email protected] nginx-1.9.7]# gedit src/core/ngx_config.h
新增
#include <ngx_posix_config.h>
---------------------------
/opt/cBPM-android/nginx-on-android/nginx-rtmp-module/ngx_rtmp_exec_module.c:774:23: error: 'PR_SET_PDEATHSIG' undeclared (first use in this function)
[[email protected] nginx-1.9.7]# gedit /opt/cBPM-android/nginx-on-android/nginx-rtmp-module/ngx_rtmp_exec_module.c
prctl(PR_SET_PDEATHSIG, e->kill_signal, 0, 0, 0);
改為:
//prctl(PR_SET_PDEATHSIG, e->kill_signal, 0, 0, 0);
---------------------------
相關推薦
(Not OK) 在CentOS7—編譯nginx—for—Android
HOST: centos 7 NGINX VERSION: nginx-1.9.7 ZLIB VERSION: zlib-1.2.8 PCRE VERSION: pcre-8.37 [[email protected] nginx-on-android]# pwd /opt/cBPM-android
NDk編譯opencv for Android,並引用在Unity3d遊戲中的一般步驟
ret app sset cpp unity3d 環境 ptr small var 本文使用:Unity3d + opencv + Android Unity3d中可以調用opencv 編譯好的.so 動態庫,在生成Android apk時可以正常運行。 因為An
使用 jenkins 自動化編譯cordova for android 生成 APK
apk app 開發 啟動 安卓 自動 class 系統 編寫 地址 引言 前文中已經介紹了什麽是cordova 為什麽要用cordova,基礎的環境搭建以及如何編譯打包生成APK安裝包,接下來我們介紹如何使用Jenkins 自動化編譯打包生成APK安裝包! 服務器搭建
Linux系統下編譯VLC for Android
操作步驟: 1、下載最新版本的Linux版jdk,將下載好的檔案解壓到/usr/android目錄下 tar zxvf jdk-10.0.2_linux-x64_bin.tar.gz 2、設定環境變數 使用sudo vi /etc/profile命令編輯環境
Mac下編譯OpenH264 for android
簡介 OpenH264 是思科的開源專案,可以編碼解碼H264,常見的H264編碼器還有x264專案。 由於OpenH264專案的文件較少,初學的門檻較高,所以整理一些文章來幫忙初學者入門。 系列文章包括: 編譯OpenH264 for Window
windows10下編譯ffmpeg for android
本文記錄在windows10下編譯ffmpeg的過程: 環境:win10 ffmpeg-3.3 ndk-r14b 注意:一般來說低版本ndk編譯的能在高版本使用,但高版本ndk編譯的無法在低版本使用,因為NDK平臺不是後向相容的,而是前向相容的,因此請根據實際情況選擇
Linux下編譯VLC for Android原始碼總結
由於專案需要,需要一個在android平臺能夠支援RTSP協議的播放器,由於之前沒有android平臺的經驗,所以找了著名的video LAN的VLC播放器,更令人驚奇的是這款播放器居然還是完全開源的。在此向那些開源軟體的作者和組織致以崇高的敬意,是你們的存在使得計算機軟
交叉編譯e2fsprogs For android
由於需要使用dumpe2fs debugfs工具,因此交叉編譯了e2fsprogs的原始碼。本人在ubuntu 14.04下操作的1. 下載e2fsprogs的原始碼版本是1.42.6 2. 下載NDKhttps://developer.android.com/ndk/
編譯boost for android經歷
主要借用這篇部落格的方法http://blog.csdn.net/lovesh5/article/details/11694941 我第一次編譯的編譯平臺是MACOSX. 1.boost庫1.49(這個是之前別人編過一次的boost庫,好幾個G,忘了在什麼平臺上編的了,應該
Ubuntu上交叉編譯valgrind for Android 4.0.4的過程與注意事項
編譯環境:Ubuntu x86_64(Linux root 2.6.32-45-generic #101-Ubuntu SMP Mon Dec 3 15:39:38 UTC 2012 x86_64 GNU/Linux) 執行環境:Android 4.0.4 (Linux
ubuntu16.04編譯opencv for Android
安裝cmake 參考這篇部落格ubuntu安裝CMake的幾種方式中的軟連結Android Sdk中的CMake 下載opencv原始碼 編譯opencv原始碼 進入原始碼目錄新建一個opencvAndroid.sh指令碼檔案,內容如下
win10子系統編譯ffmpeg for android遇到的問題記錄
makefile:2: ffbuild/config.mak: no such file or directory 還有一些其他自動生成的檔案都找不到 解決方案 首先只執行./configure + 引數(注意不要有–list-等會執行相關命令的引數之類的
[Android]編譯錯誤:Could not get unknown property 'release' for SigningConfig container
在寫gradle指令碼時,出現:Could not get unknown property 'release' for SigningConfig container的錯誤。 出現這種錯誤的原因有:
加快QT工程編譯速度(還可給Qt for Android設置)
qmake targe 沒有 利用 tools too blank tab 這樣的 一、多核編譯 環境:win10, Qt 5.4.1,編譯器mingw32 項目: Qt for Android Qt Creator 在編譯android項目時不支持預編譯,默認cpu
OSG for android的編譯總結
display article 原因 mat cygwin 動態鏈接 cep evel arr 最近對OSG進行了android下的編譯。簡單總結一下: 0.介紹下環境:WIN7 64位 + cygwin32位 + OSG3.2.0 1.首先介紹幾篇博文,參考了不少,但並沒
CentOS7編譯安裝Nginx
pre 重新 openss uwsgi isa HR 文件 bsp 存在 一、簡介 Nginx("engine x")是一款是由俄羅斯的程序設計師Igor Sysoev所開發高性能的 Web和 反向代理 服務器,也是一個 IMAP/POP3/SMTP 代理服務器
centos7編譯安裝nginx及無縫升級https
itl download err sha2 進行 ast ref 配置文件 CP 安裝依賴: [html] view plain copy yum install -y gcc-c++ pcre pcre-devel zlib z
阿裏雲centOS7.4 nginx: [emerg] "server" directive is not allowed here in /etc/nginx/vhost/xxxxxx.conf:2
站點 all span 阿裏雲 src etc local roc end 裏雲centOS7.4配置多個站點遇到的問題nginx: [emerg] "server" directive is not allowed here in /etc/nginx/vhost/xxx
AndroidStudio導入Eclipse項目報錯Error:Could not determine the class-path for interface com.android.builder.model.AndroidProject
and art cli mode log RF details get ID AndroidStudio導入Eclipse項目報錯 Error:Could not determine the class-path for interface com.android.buil
Mac下編譯JRTPLIB原始碼 For Android
一.工欲善其事必先利其器: 1.官網下載Jthread和Jrtplib 2.通過 "brew install ninja" 命令安裝ninja 二.解壓下載的Jthread與Jrtplib壓縮包並參考GitHub的文件編寫cmake檔案: 1.在Jthread解壓出的目錄下建立toolcha