-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compile with static php shows error #4172
Comments
Recently I tried to build an php statically linked binary with swoole and some other extensions, to make php real portable, flexible. But I have some trouble, like this issue. Now I can successfully build it and run my own swoole application with no dependencies. But I still cannot compile xml(libxml2 required) and curl(libcurl required), some environment problem have not been solved. |
I successfully built it with xml and curl. https://github.com/crazywhalecc/static-php-swoole But it seems php 7.3 cannot be compiled (swoole 4.6.6) and it shows another error like |
@crazywhalecc You should enable hash extension |
same error when static compile swoole4.6.6 php7.4.19 in alpine
dockerfile https://github.com/suconghou/docker/blob/master/php/74/Dockerfile-swoole you can see all the configuration and produce this error easily |
Another problem: when using |
configure arguments: ./configure LDFLAGS=-static --prefix=/static-php-cli/php-dist --disable-all --enable-shared=no --enable-static=yes --enable-inline-optimization --with-layout=GNU --enable-calendar --enable-ctype --enable-filter --enable-openssl --enable-bcmath --with-openssl-dir=/usr --enable-pcntl --enable-openssl --with-openssl --with-iconv --enable-json --enable-mbstring --enable-phar --enable-pdo --with-pdo-mysql=mysqlnd --enable-sockets --with-curl --enable-swoole --enable-swoole-curl --enable-inotify --enable-redis --disable-redis-session --enable-simplexml --enable-dom --enable-xml --enable-xmlwriter --enable-xmlreader --with-zlib --enable-posix --enable-mysqlnd --enable-tokenizer --with-pear=no --disable-cgi --disable-phpdbg --enable-gd --with-libxml make command: make LDFLAGS=-ldl -j8 && make install And curl is compiled manually, using arguments: CC=gcc CXX=g++ CFLAGS=-fPIC CPPFLAGS=-fPIC ./configure --prefix="$_opt_dir/curl" \
--without-nghttp2 \
--with-ssl=/usr \
--with-pic=pic \
--enable-ipv6 \
--enable-shared=no \
--enable-static=yes \
--without-libidn2 \
--disable-ldap \
--without-libpsl \
--without-lber \
--enable-ares |
@crazywhalecc ty for this https://github.com/crazywhalecc/static-php-cli/blob/master/docker/check-extensions.sh#L226 it saved my life. |
it's written by me, a temporary solution 😢 , and this issue is created for it. |
And did Also, I had to add a |
Yeah, it's the only solution for compiling static php I think. |
Unfortunately If I am in Alpine and I compile SAPI https://github.com/php/php-src/search?q=%22-export-dynamic%22 Maybe I am confusing about shared or static extensions versus system libraries. At the end using the |
FYI https://github.com/wandersonwhcr/docker-php-smallest/blob/main/Base.Dockerfile#L28 |
export LDFLAGS="-all-static"
make -j cli
more info https://github.com/php/php-src/blob/bbe42a5ccd9edfee3a85cbf5a1b6b86054ddeb58/build/ltmain.sh#L1193 or sed -i 's/-export-dynamic/-all-static/g' Makefile
make -j cli
两种都可以 |
Please answer these questions before submitting your issue. Thanks!
compile static swoole and php. Scripts:
What did you expect to see?
Compile success with an php binary.
What did you see instead?
What version of Swoole are you using (show your
php --ri swoole
)?latest version(github), commit: e86eac3
What is your machine environment used (show your
uname -a
&php -v
&gcc -v
) ?The text was updated successfully, but these errors were encountered: