-
-
Notifications
You must be signed in to change notification settings - Fork 233
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
Cannot be statically built #393
Comments
Hi @char101 What is the reason for the need for static build? |
Because it is supported by PHP. https://www.php.net/manual/en/install.pecl.static.php In my case I want to compile a static php binary so that it can be deployed along the application. There is no fix required for this. I only put it here since other people who want to compile the extension statically might find it useful. If you don't want to support the case of statically linking the extension please close the issue. |
I think this benefit may be small. Even if compiled statically, the binary file still depends on the external library, and you cannot directly copy the executable file and run it anywhere. Or you have a way to solve this problem, if you don’t mind, I would love to know your working method, thank you. |
The benefit of a static php binary is exactly that it does not depend on any shared library and can be just copied to and run in another machine. In fact I have just compiled a static php executable with this extension embedded statically.
There is also this repository https://github.com/crazywhalecc/static-php-cli that provides a build script although I don't use it (I use my own build script). |
Wow, this is great, are you interested in making your script public? |
It is not a simple script, there are several alpine linux packages that need to be rebuild and there are some extensions that need to be modified. |
@viest xlsWriter是一个非常好的项目,我们在我们的代码里广泛使用了xlsWriter。 |
静态编译报错信息:
|
静态编译命令: git clone -b php-8.2.4 --depth=1 https://github.com/php/php-src.git
git clone -b v1.5.4 --depth=1 --recursive https://github.com/viest/php-ext-xlswriter.git
mv php-ext-xlswriter xlswriter
mv xlswriter php-src/ext/
cd php-src/
./buildconf --force
export CPPFLAGS=' -I/usr/libiconv/include -I/usr/bzip2/include -I/usr/zlib/include -I/usr/libxml2/include/libxml2 -I/usr/libiconv/include '
export LDFLAGS=' -L/usr/libiconv/lib -L/usr/bzip2/lib -L/usr/zlib/lib -L/usr/libxml2/lib -L/usr/libiconv/lib '
export LIBS=' -liconv -lbz2 -lz -lxml2 -liconv -lm -lstdc++'
./configure --prefix=/tmp/php-8.2.4 \
--disable-all \
--disable-cgi \
--disable-phpdbg \
--enable-shared=no \
--enable-static=yes \
--enable-cli \
--with-iconv=/usr/libiconv \
--with-bz2=/usr/bzip2 \
--enable-filter \
--enable-session \
--enable-tokenizer \
--enable-ctype \
--with-zlib --with-zlib-dir=/usr/zlib \
--enable-posix \
--enable-phar \
--enable-fileinfo \
--enable-xml --enable-simplexml --enable-xmlreader --enable-xmlwriter --enable-dom --with-libxml \
--with-xlswriter --enable-reader
export LDFLAGS="$LDFLAGS -all-static"
make -j $(nproc) cli
命令来自: https://github.com/jingjingxyk/swoole-cli/tree/build_native_php |
Hi,
This extension cannot be statically built into php and can only be build using using phpize, because of several factors
$srcdir
should be$ext_srcdir
, and$builddir
should be$ext_builddir
$ext_srcdir
and$ext_builddir
are defined byPHP_NEW_EXTENSION
, before it we need to usePHP_EXT_SRCDIR
andPHP_EXT_BUILDDIR
macros.The text was updated successfully, but these errors were encountered: