我试图用OpenSSL在Linux上静态编译python3.6。在
我的构建是在dockerfile中进行的,但实际上是:$ ./configure --prefix=/task/build --disable-shared LDFLAGS="-static"
$ make altinstall
通过对Modules/Setup.local的更新使其看起来像:
^{pr2}$
但是,在配置步骤中,我得到错误:Step 9/14 : RUN ./configure --prefix=/task/build --disable-shared LDFLAGS="-static"
---> Running in cb79ee47052b
checking for git... found
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for python3.6... no
checking for python3... no
checking for python... python
checking for --enable-universalsdk... no
checking for --with-universal-archs... no
checking MACHDEP... linux
checking for --without-gcc... no
checking for --with-icc... no
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/task/cpython':
configure: error: C compiler cannot create executables
See `config.log' for more details
The command '/bin/sh -c ./configure --prefix=/task/build --disable-shared LDFLAGS="-static"' returned a non-zero code: 77
如果我将configure命令更改为:$ ./configure --prefix=/task/build --disable-shared
我得到了一个编译后的二进制文件,但它没有静态链接到OpenSSL。在
我做错什么了?在
谢谢!在
构建dockerfile:FROM amazonlinux:2017.03.1.20170812
ARG python_version=3.6.8
WORKDIR /task
COPY Modules-Setup.local /task/Modules-Setup.local
# Install requirements
RUN yum install -y \
gcc \
git \
gzip \
openssl-devel \
tar \
zlib \
zlib-devel
# Get openssl and python source
RUN git clone https://github.com/python/cpython.git
WORKDIR /task/cpython
RUN git checkout tags/v${python_version}
# Configure the build
RUN ./configure --prefix=/task/build --disable-shared LDFLAGS="-static"
# append modules setup with custom values
RUN cat /task/Modules-Setup.local >> /task/cpython/Modules/Setup.local
RUN cat /task/cpython/Modules/Setup.local
# Build
RUN make altinstall
# Zip the results
WORKDIR /task/build
RUN tar --create --gzip --file=/task/python-${python_version}.tar.gz \
lib/ bin/