简体   繁体   English

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

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

I am trying to cross compile PostgreSQL on an x86 host for an AArch64 target, and want to compile with OpenSSL support.我正在尝试在 x86 主机上为 AArch64 目标交叉编译 PostgreSQL,并希望在 OpenSSL 支持下进行编译。

I already went ahead and successfully cross compiled OpenSSL for AArch64 using the following arguments:我已经继续并使用以下 arguments 为 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

Now on to cross compiling PostgreSQL, I am using the following build script:现在开始交叉编译 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)

The output of the configure commands shows that the include directory has been properly set:配置命令的 output 显示包含目录已正确设置:

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/

Running the make command fails on:运行make命令失败:

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

However if I run find../../openssl-OpenSSL_1_1_1k/build_aarch64/packaged/include/ | grep opensslconf.h但是,如果我运行find../../openssl-OpenSSL_1_1_1k/build_aarch64/packaged/include/ | grep opensslconf.h find../../openssl-OpenSSL_1_1_1k/build_aarch64/packaged/include/ | grep opensslconf.h it outputs: 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

so the file is definitely there in the include paths.所以该文件肯定存在于包含路径中。 Is this a bug?这是一个错误吗? Am I doing something incorrectly?我做错了什么吗?

Figured it out, looks like I had to use absolute paths instead of relative paths for the search directories:想通了,看起来我必须使用绝对路径而不是搜索目录的相对路径:

../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/

So basically just added $(pwd)/ to the start of the search directory paths.所以基本上只是将$(pwd)/添加到搜索目录路径的开头。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM