<div dir="ltr"><div>Hello,<br>As you can see, boringssl's libcrypto.a and libssl.a are in two separate directories, as shown below:<br><font size="1">root@VM-8-12-debian ~/boringssl/build # ls<br>bssl CMakeCache.txt cmake_install.cmake crypto_test decrepit embed_test_data_args.txt libpki.a pki_test ssl_test urandom_test<br>build.ninja CMakeFiles crypto crypto_test_data.cc decrepit_test libboringssl_gtest.a libtest_support_lib.a ssl tool util<br>root@VM-8-12-debian ~/boringssl/build # cd crypto<br>root@VM-8-12-debian ~/boringssl/build/crypto # ls<br>chacha cipher_extra CMakeFiles cmake_install.cmake crypto_test err_data.c fipsmodule libcrypto.a test urandom_test<br>root@VM-8-12-debian ~/boringssl/build/crypto # cd ..<br>root@VM-8-12-debian ~/boringssl/build # cd ssl<br>root@VM-8-12-debian ~/boringssl/build/ssl # ls<br>CMakeFiles cmake_install.cmake libssl.a ssl_test test</font><br><br>I tried using absolute paths and adding -Wl,-rpath=/root/boringssl/build/ssl -Wl,-rpath=/root/boringssl/build/crypto -Wl,--enable-new-dtags but this Doesn't play any role.<br><br><span class="gmail_signature_prefix">--</span><br><div dir="ltr" class="gmail_signature"><div dir="ltr">Best Regards,<br>Jinze Yang</div></div><br></div>-------------------------------------------------------<br>> On Tue, Feb 20, 2024 at 12:23 AM 杨金泽 <<a href="mailto:rttwyjz@gmail.com">rttwyjz@gmail.com</a>> wrote:<br>> ><br>> > I encountered the following error when using boringssl to build<br>> Nginx:<br>> > checking for OpenSSL library ... not found<br>> > checking for OpenSSL library in /usr/local/ ... not found<br>> > checking for OpenSSL library in /usr/pkg/ ... not found<br>> > checking for OpenSSL library in /opt/local/ ... not found<br>> > ./auto/configure: error: SSL modules require the OpenSSL library.<br>> > You can either do not enable the modules, or install the OpenSSL<br>> library<br>> > into the system, or build the OpenSSL library statically from the<br>> source<br>> > with nginx by using --with-openssl=<path> option.<br>> ><br>> > At first I thought it was caused by openssl not existing, but when I<br>> ran openssl version -a, everything was normal:<br>> > root@iZ2hmeokcpbj42Z ~/nginx # openssl version -a<br>> > OpenSSL 3.0.11 19 Sep 2023 (Library: OpenSSL 3.0.11 19 Sep 2023)<br>> > built on: Mon Oct 23 17:52:22 2023 UTC<br>> > platform: debian-amd64<br>> > options: bn(64,64)<br>> > compiler: gcc -fPIC -pthread -m64 -Wa,--noexecstack -Wall<br>> -fzero-call-used-regs=used-gpr -DOPENSSL_TLS_SECURITY_LEVEL=2<br>> -Wa,--noexecstack -g -O2 -ffile-prefix-map=<br>> /build/reproducible-path/openssl-3.0.11=. -fstack-protector-strong<br>> -Wformat -Werror=format-security -DOPENSSL_USE_NODELETE -DL_ENDIAN<br>> -DOPENSSL_PIC -DOPENSSL_BUILDING_OPENSSL -DNDEBUG -Wdate-time<br>> -D_FORTIFY_SOURCE=2<br>> > OPENSSLDIR: "/usr/lib/ssl"<br>> > ENGINESDIR: "/usr/lib/x86_64-linux-gnu/engines-3"<br>> > MODULESDIR: "/usr/lib/x86_64-linux-gnu/ossl-modules"<br>> > Seeding source: os-specific<br>> > CPUINFO: OPENSSL_ia32cap=0xfffa32035f8bffff:0xd01e4fbb<br>> ><br>> > Later my friend and I discovered that the latest boringssl<br>> compatible OpenSSL version seems to have been upgraded to 3.2.x, but I<br>> am not sure if this is the problem. The final solution was to switch<br>> to <a href="https://github.com/google/boringssl">https://github.com/google/boringssl</a><br>> /commit/c39e6cd9ec5acebb6de2adffc03cfe03b07f08ab this commit.But I<br>> don't think switching to a previous commit to build is a perfect<br>> solution, so I'd like to ask for some help.<br>> ><br>> > My build steps are as follows:<br>> > apt update<br>> > apt install build-essential ca-certificates zlib1g-dev libpcre3<br>> libpcre3-dev tar unzip libssl-dev wget curl git cmake ninja-build<br>> mercurial libunwind-dev pkg-config<br>> ><br>> > git clone <a href="https://github.com/google/boringssl.git">https://github.com/google/boringssl.git</a><br>> > cd boringssl<br>> > mkdir build<br>> > cd build<br>> > cmake -GNinja ..<br>> > ninja<br>> > cd ../..<br>> ><br>> > git clone --recurse-submodules -j8<br>> <a href="https://github.com/google/ngx_brotli">https://github.com/google/ngx_brotli</a><br>> > cd ngx_brotli/deps/brotli<br>> > mkdir out && cd out<br>> > cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF<br>> -DCMAKE_C_FLAGS="-Ofast -m64 -march=native -mtune=native -flto<br>> -funroll-loops -ffunction-sections -fdata-sections -Wl,--gc-sections"<br>> -DCMAKE_CXX_FLAGS ="-Ofast -m64 -march=native -mtune=native -flto<br>> -funroll-loops -ffunction-sections -fdata-sections -Wl,--gc-sections"<br>> -DCMAKE_INSTALL_PREFIX=./installed ..<br>> > cmake --build . --config Release --target brotlienc<br>> > cd ../../../..<br>> ><br>> > hg clone <a href="https://hg.nginx.org/nginx">https://hg.nginx.org/nginx</a><br>> > cd nginx<br>> > ./auto/configure --user=www --group=www --prefix=/www/server/nginx<br>> --with-pcre --add-module=/root/ngx_brotli --with-http_v2_module<br>> --with-stream --with-stream_ssl_module --with-http_ssl_module<br>> --with-http_gzip_static_module --with-http_gunzip_module<br>> --with-http_sub_module --with-http_flv_module<br>> --with-http_addition_module --with-http_realip_module<br>> --with-http_mp4_module --with-ld -opt=-Wl,-E --with-cc-opt=-Wno-error<br>> --with-ld-opt=-ljemalloc --with-http_dav_module --with-http_v3_module<br>> --with-cc-opt=-I ../boringssl/include<br>> --with-ld-opt='-L../boringssl/build/ssl -L../boringssl/build/crypto'<br>> > make<br>> > make install<br>> ><br>> > System information:<br>> > checking for OS<br>> > + Linux 6.1.0-18-amd64 x86_64<br>> > checking for C compiler ... found<br>> > + using GNU C compiler<br>> > + gcc version: 12.2.0 (Debian 12.2.0-14)<br>> <br>> This does not look correct to me, based on my knowledge of OpenSSL. (I<br>> don't have experience with BoringSSL):<br>> <br>>     --with-ld-opt='-L../boringssl/build/ssl<br>> -L../boringssl/build/crypto'<br>> <br>> You are trying to link two OpenSSL-compatible libraries. They are<br>> libcrypto.{a|so}, and libssl.{a|so}. Those artifacts are usually<br>> placed in a  lib/ directory, not in separate ssl/ and crypto/<br>> directories. (Two separate directories may be a BoringSSL-ism).<br>> <br>> So I believe the proper flag would be similar to:<br>> <br>>     --with-ld-opt='-L../boringssl/build/lib<br>> <br>> You should also consider using the the following option so the library<br>> used at runtime is the same library used at compile and link time:<br>> <br>>     -Wl,-rpath=../boringssl/build/lib -Wl,--enable-new-dtags<br>> <br>> But you should change ../boringssl/build/lib to the full path, and not<br>> use the relative path.<br>> <br>> Also see<br>> <<a href="https://wiki.openssl.org/index.php/Compilation_and_Installation#Using">https://wiki.openssl.org/index.php/Compilation_and_Installation#Using</a><br>> _RPATHs><br>> or the BoringSSL equivalent document.<br>> <br>> Jeff<br>> _______________________________________________<br>> nginx mailing list<br>> <a href="mailto:nginx@nginx.org">nginx@nginx.org</a><br>> <a href="https://mailman.nginx.org/mailman/listinfo/nginx">https://mailman.nginx.org/mailman/listinfo/nginx</a></div>