Skip to content
Jefferson González edited this page Jan 22, 2015 · 1 revision

Statically linking is a good idea to package wxphp into rmp/deb files without dependencies on third party wxGTK packages that may be incompatible. Since on Windows wxWidgets is statically linked to the wxPHP library by default, this page will just discuss how to do it on Linux/Unix/MacOSX platforms. Before we start, on 64 bits static linking is impossible without the use of -fPIC, knowing that here are the steps involved to achieve it:

Compile wxWidgets with -fPIC

CFLAGS="-fPIC -O2 -Wall -W" CXXFLAGS="-fPIC -O2" \
./configure --prefix=/opt/wxWidgets-static --disable-shared --enable-monolithic

Run the generated wxphp configure script with custom ld flags

LDFLAGS="-L/opt/wxWidgets-static/lib -pthread -lwx_gtk2u-2.9 -lwx_gtk2u_gl-2.9 -lwxregexu-2.9 -lwxscintilla-2.9 -lwxtiff-2.9" \
./configure --with-wxwidgets=/opt/wxWidgets-static --enable-wxwidgets-monolithic

Strip debugging symbols for smaller library size

strip modules/wxwidgets.so

If a smaller library size is wanted it could be achieved by playing with the GCC optimization flags, when compiling the wxWidgets library on the first step as on the second step. Some flags that could reduce the file size (a little bit) of final libraries as increase performance could be -Os and -s for example:

CFLAGS="-fPIC -Os -s" CXXFLAGS="-fPIC -Os -s"

Clone this wiki locally