简体   繁体   中英

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.

I already went ahead and successfully cross compiled OpenSSL for AArch64 using the following arguments:

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

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:

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:

/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 it outputs:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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