关于 libcrypt 和 libcrypto ,以及编译 nginx 的两个坑

termux 官方库的 nginx 自带的模块不是很全,于是尝试编译安装。

首先用官方库的 nginx 执行了一下 nginx -V ,记录了一下官方的编译参数。

1
--prefix=/data/data/com.termux/files/usr --crossbuild=Linux:3.16.1:aarch64 --crossfile=/home/builder/.termux-build/nginx/src/auto/cross/Android --with-cc=aarch64-linux-android-clang --with-cpp=aarch64-linux-android-cpp --with-cc-opt=' -I/data/data/com.termux/files/usr/include -DIOV_MAX=1024 -fstack-protector-strong -Oz' --with-ld-opt='-L/data/data/com.termux/files/usr/lib -Wl,-rpath=/data/data/com.termux/files/usr/lib -fopenmp -static-openmp -Wl,--enable-new-dtags -Wl,--as-needed -Wl,-z,relro,-z,now -landroid-glob' --with-threads --sbin-path=/data/data/com.termux/files/usr/bin/nginx --conf-path=/data/data/com.termux/files/usr/etc/nginx/nginx.conf --http-log-path=/data/data/com.termux/files/usr/var/log/nginx/access.log --pid-path=/data/data/com.termux/files/usr/tmp/nginx.pid --lock-path=/data/data/com.termux/files/usr/tmp/nginx.lock --error-log-path=/data/data/com.termux/files/usr/var/log/nginx/error.log --http-client-body-temp-path=/data/data/com.termux/files/usr/var/lib/nginx/client-body --http-proxy-temp-path=/data/data/com.termux/files/usr/var/lib/nginx/proxy --http-fastcgi-temp-path=/data/data/com.termux/files/usr/var/lib/nginx/fastcgi --http-scgi-temp-path=/data/data/com.termux/files/usr/var/lib/nginx/scgi --http-uwsgi-temp-path=/data/data/com.termux/files/usr/var/lib/nginx/uwsgi --with-http_auth_request_module --with-http_ssl_module --with-http_v2_module --with-http_gunzip_module --with-http_sub_module --with-stream --with-stream_ssl_module

删除掉与交叉编译相关的参数,然后尝试直接正常 make 流程编译,报错。
第一次报错.jpg

我选择直接修改 eventpoll.h ,将报错中提到的宏常量前面的修饰删掉,这个报错解决。

第二次 make,链接器报错:找不到符号 crypt 。很疑惑,网上找了半天没有类似问题。仔细审视传给链接器的参数,发现只有 -lcrypto , 没有 -lcrypt(没有截图,当时显示的 crypto 正好在 t 和 o 之间换行了)。在 configure 的参数中加上了 -lcrypt ,问题解决。

1
--prefix=/data/data/com.termux/files/usr --with-cc-opt=' -I/data/data/com.termux/files/usr/include -DIOV_MAX=1024 -fstack-protector-strong -Oz' --with-ld-opt='-L/data/data/com.termux/files/usr/lib -Wl,-rpath=/data/data/com.termux/files/usr/lib -fopenmp -static-openmp -Wl,--enable-new-dtags -Wl,--as-needed -Wl,-z,relro,-z,now -landroid-glob -lcrypt' --with-threads --sbin-path=/data/data/com.termux/files/usr/bin/nginx --conf-path=/data/data/com.termux/files/usr/etc/nginx/nginx.conf --http-log-path=/data/data/com.termux/files/usr/var/log/nginx/access.log --pid-path=/data/data/com.termux/files/usr/tmp/nginx.pid --lock-path=/data/data/com.termux/files/usr/tmp/nginx.lock --error-log-path=/data/data/com.termux/files/usr/var/log/nginx/error.log --http-client-body-temp-path=/data/data/com.termux/files/usr/var/lib/nginx/client-body --http-proxy-temp-path=/data/data/com.termux/files/usr/var/lib/nginx/proxy --http-fastcgi-temp-path=/data/data/com.termux/files/usr/var/lib/nginx/fastcgi --http-scgi-temp-path=/data/data/com.termux/files/usr/var/lib/nginx/scgi --http-uwsgi-temp-path=/data/data/com.termux/files/usr/var/lib/nginx/uwsgi --with-http_auth_request_module --with-http_ssl_module --with-http_v2_module --with-http_gunzip_module --with-http_sub_module --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-http_stub_status_module --with-http_gzip_static_module

  • libcrypt 是 glibc 的一个库;
  • libcrypto 是 openssl 的一个库。