无法使用 OpenSSL 交叉编译 PostgreSQL,失败 <openssl/opensslconf.h> 未找到 - 尽管指定了包含搜索路径

Unable to cross compile PostgreSQL with OpenSSL, fails on <openssl/opensslconf.h> not found - despite specifying include search path

我正尝试在 x86 主机上为 AArch64 目标交叉编译 PostgreSQL,并希望在支持 OpenSSL 的情况下进行编译。

我已经使用以下参数成功地为 AArch64 交叉编译了 OpenSSL:

../Configure linux-aarch64 --prefix=$(pwd)/packaged no-dso --cross-compile-prefix="/usr/bin/aarch64-linux-gnu-"
make -j$(nproc)
make -j$(nproc) install

现在开始交叉编译 PostgreSQL,我使用以下构建脚本:

test -e postgresql-12.2.tar.gz || wget https://ftp.postgresql.org/pub/source/v12.2/postgresql-12.2.tar.gz
test -e postgresql-12.2 || tar -xzvf postgresql-12.2.tar.gz
cd postgresql-12.2
test -e build_aarch64 && rm -rf build_aarch64
mkdir build_aarch64
cd build_aarch64
../configure --host=aarch64-linux-gnu --without-readline --without-zlib CFLAGS="-O3 -fPIC" CXXFLAGS="-fPIC" CPPFLAGS="-fPIC" --prefix=$PWD/packaged USE_DEV_URANDOM=1 --with-openssl --with-libraries=../../openssl-OpenSSL_1_1_1k/build_aarch64/packaged/lib/ --with-includes=../../openssl-OpenSSL_1_1_1k/build_aarch64/packaged/include/
make -j$(nproc)

配置命令的输出显示包含目录已正确设置:

configure: using CPPFLAGS=-fPIC -D_GNU_SOURCE  -I../../openssl-OpenSSL_1_1_1k/build_aarch64/packaged/include/
configure: using LDFLAGS=  -L../../openssl-OpenSSL_1_1_1k/build_aarch64/packaged/lib/

运行 make 命令失败:

/usr/include/openssl/e_os2.h:13:11: fatal error: openssl/opensslconf.h: No such file or directory
   13 | # include <openssl/opensslconf.h>

但是如果我 运行 find ../../openssl-OpenSSL_1_1_1k/build_aarch64/packaged/include/ | grep opensslconf.h 它输出:

../../openssl-OpenSSL_1_1_1k/build_aarch64/packaged/include/openssl/opensslconf.h

所以文件肯定在包含路径中。这是一个错误吗?我做错了什么吗?

想通了,看起来我必须使用绝对路径而不是搜索目录的相对路径:

../configure --host=aarch64-linux-gnu --without-readline --without-zlib CFLAGS="-O3 -fPIC" CXXFLAGS="-fPIC" CPPFLAGS="-fPIC" --prefix=$PWD/packaged USE_DEV_URANDOM=1 --with-openssl --with-libraries=$(pwd)/../../openssl-OpenSSL_1_1_1k/build_aarch64/packaged/lib/ --with-includes=$(pwd)/../../openssl-OpenSSL_1_1_1k/build_aarch64/packaged/include/

所以基本上只是将 $(pwd)/ 添加到搜索目录路径的开头。