Goal: a single script that produces a self-contained PhantomJS executable with virtually no dependency.
The script needs to do the following:
The script must run on macOS, Windows, and Linux (32-bit and 64-bit). The produced binaries will be made available from http://phantomjs.org/download.html.
NOTE: This is not intended for a distribution packager who wants to package PhantomJS for Debian/Fedora/Homebrew/etc. See #14458 for some additional context.
This is also important to support installer wrapper such as:
So I got tired of waiting and figured out how to do this, mostly based on build.py. Here goes.
I did this on Ubuntu 16.10.
!win32:!winrt: SUBDIRS += phantom (again, the forked qtbase had this, to activate the platform plugin)./configure -static -release -prefix . -opensource -confirm-license -qpa phantom -openssl -openssl-linked -no-openvg -no-eglfs -no-egl -no-glib -no-gtk -no-cups -no-sm -no-xkb -no-xcb -no-kms -no-linuxfb -no-directfb -no-mirclient -no-mtdev -no-libudev -no-evdev -no-pulseaudio -no-alsa -no-feature-PRINTPREVIEWWIDGET -fontconfig -icu -qt-zlib -qt-libpng -qt-libjpeg -qt-pcre -nomake examples -nomake tools -nomake tests -no-qml-debug -no-dbus -no-opengl -no-audio-backend -D QT_NO_GRAPHICSVIEW -D QT_NO_GRAPHICSEFFECT -D QT_NO_STYLESHEET -D QT_NO_STYLE_CDE -D QT_NO_STYLE_CLEANLOOKS -D QT_NO_STYLE_MOTIF -D QT_NO_STYLE_PLASTIQUE -D QT_NO_PRINTPREVIEWDIALOG -no-pkg-config
make -j4). No need to install it, but this directory will now act as the installation prefix./usr/bin/qmake, which is part of the qtchooser package on ubuntu (couldn't uninstall that because of dependencies, so it was pointing to a nonexistent qmake), to make sure it found my qmake, not that one.qmake && make && make install. It'll install to your qtbase directory.add_definitions(-DQT_NO_GRAPHICSVIEW) under add_definitions(-DBUILDING_QT__=1) . I don't know why it's not picking this up from Qt, since it was built with QT_NO_GRAPHICSVIEW, but this was the only way to make it build.add_subdirectory(QtTestBrowser). QTestBrowser won't build without GraphicsView, but we don't need it.mkdir -p WebKitBuild/Release && cd WebKitBuild/Release
cmake -DPORT=Qt -DCMAKE_INSTALL_PREFIX="$WORKDIR"/qtbase -DCMAKE_BUILD_TYPE=Release -DQT_QMAKE_EXECUTABLE="$WORKDIR"/qtbase/bin/qmake -DCMAKE_PREFIX_PATH="$WORKDIR"/qtbase -DUSE_GSTREAMER=OFF -DENABLE_OPENGL=OFF -DENABLE_WEB_AUDIO=OFF -DENABLE_VIDEO=OFF -DENABLE_WEBKIT2=OFF -DENABLE_NETSCAPE_PLUGIN_API=OFF -DENABLE_TEST_SUPPORT=off -DQT_STATIC_BUILD=on -DENABLE_API_TESTS=off -DUSE_THIN_ARCHIVES=off ../..
make -j4
make install
Replace $WORKDIR with the directory where qtbase is located.
I don't know if -DQT_STATIC_BUILD=on is needed, since webkit's Makefile should set that automatically, but I set it just in case. These options are mostly based on how build.py disabled features when building qtwebkit, I tried to find their equivalents here, but I couldn't find all of them. I also disabled the tests, since they failed to build because of missing graphicsview.
Make install will install it to your qtbase directory
export WEB_INSPECTOR_RESOURCES_DIR="$WORKDIR/webkit//WebKitBuild/Release/DerivedSources/WebInspectorUI/"LFLAGS and add -static-libstdc++ -static-libgcc. This was needed to get the binary that I built on Ubuntu 16.10 to work on Debian Jessie. I think the old 2.1.1 build script got away with dynamically linking the standard libraries by building on Wheezy, so the standard libraries were old enough to work on most distros. That's also an option.LIBS. I had to remove -lQt5DBus (qt was built without dbus, and I couldn't figure out why this was being added), add -lQt5Positioning, -lQt5Sensors (this can probably be added in the pro file, but I was lazy)LIBS. I built qtbase with -qt-libpng, based on build.py, but when I built phantomjs, I think it tried to use the system libpng as well, and ended up looking for a symbol that only exists in libpng 16, which was installed on my system. So I just replaced -lqtpng with -l:libpng.a (since I wanted to link it statically).-lXXX to -l:libXXX.a: crypto, hyphen, webp, z, png, icui18n, icuuc icudata. In the end it looked like this:LIBS = $(SUBLIBS) -L/home/nkovacs/progs/phantomjs2/phantomjs/src/qt-qpa-platform-plugin/plugins/platforms -lqphantom -lgthread-2.0 -pthread -lglib-2.0 -lXrender -lXext -lX11 -linput -lxkbcommon -ludev -lmtdev -lEGL -lGL -L/home/nkovacs/progs/phantomjs2/qtbase/lib/x86_64-linux-gnu -lQt5WebKitWidgets -L/home/nkovacs/progs/phantomjs2/qtbase/lib -lQt5Sensors -lQt5PrintSupport -lQt5Widgets -lQt5WebKit -lQt5PlatformSupport -lQt5Positioning -lfontconfig -lfreetype -L/home/nkovacs/progs/phantomjs2/qtbase/plugins/imageformats -lqico -lQt5Gui -lharfbuzz -L/home/nkovacs/progs/phantomjs2/qtbase/plugins/bearer -lqgenericbearer -lQt5Network -lssl -l:libcrypto.a -L/home/nkovacs/progs/phantomjs2/qtbase/plugins/sqldrivers -lqsqlite -lQt5Sql -lQt5Core -lqtpcre -lm -ldl -lrt -lpthread -lWebCore -lJavaScriptCore -lWTF -lxml2 -lbmalloc -lxslt -l:libhyphen.a -l:libwebp.a -lwoff2 -lbrotli -lfontconfig -l:libz.a -lfreetype -lQt5Sensors -l:libpng.a -l:libicui18n.a -l:libicuuc.a -l:libicudata.a
The binary seems to work fine, and it runs on Debian Jessie. However, the remote debugger can't find its resources. I've uploaded it here: https://github.com/nkovacs/selenium-standalone-phantomjs/tree/b5c20ef4eba3395bf23d5228d480810f3e4378f9
@nkovacs thank you for this detailed instruction! I have some comments below:
First, I had to uninstall qmake and the qt development packages, because it was conflicting with the static qt I had to build.
You don't need to. You need to specify the correct qmake.
symlink the phantom qt platform plugin into the qt source code (phantomjs 2.1.1 had the phantom plugin in its forked version of qtbase, so I duplicated that. I don't know if this is necessary, I don't know what I'm doing.)
No needs to do that. Current master already includes the needed platform plugin that will be built on Linux.
-qt-zlib -qt-libpng -qt-libjpeg
This is dangerous and can lead to unpredicted behaviour. If you are building QtWebKitNG in-the-source (qt5.git), you can use bundled libraries, but not for out-of-the-source (like in your instruction), it's better to use system libraries.
Clone https://github.com/qt/qtlocation and https://github.com/qt/qtsensors,
These components are optional. Here is the list of Qt modules that you need for specific functionality:
Geolocation - qtlocation
Device Orientation - qtsensors
Multimedia (audio/video) - qtmultimedia
Instead of using this huge repo, I suggest to use qtwebkit-snapshots
10 and 11
Again, you don't need to hack CMake configuration, just use this command to build QtWebKitNG:
./Tools/Scripts/build-webkit --qt --release --no-device-orientation \
--no-web-audio --no-video --no-video-track --no-touch-events \
--no-touch-slider --no-geolocation --no-netscape-plugin-api --64-bit \
--cmakeargs="-Wno-dev -DCMAKE_PREFIX_PATH={PATH_TO_YOUR_QT_BUILD} -DUSE_GSTREAMER=OFF -DUSE_THIN_ARCHIVES=OFF -DENABLE_API_TESTS=OFF -DENABLE_TEST_SUPPORT=OFF -ENABLE_OPENGL=NO"
Thanks, I'll try your suggestions.
You don't need to. You need to specify the correct qmake.
I did that (-DQT_QMAKE_EXECUTABLE), but it wasn't working for some reason. Also, -DCMAKE_PREFIX_PATH didn't work, it was still picking up the system qt cmake files. When I uninstalled the ubuntu dev packages, it found the static qt's cmake files instead.
This is dangerous and can lead to unpredicted behaviour. If you are building QtWebKitNG in-the-source (qt5.git), you can use bundled libraries, but not for out-of-the-source (like in your instruction), it's better to use system libraries.
I took that from build.py: https://github.com/ariya/phantomjs/blob/2.1.1/build.py#L254
So I should leave that out and just statically link the system libraries to phantomjs? I think jpeg isn't used by phantomjs btw.
Instead of using this huge repo, I suggest to use qtwebkit-snapshots
Or just git clone --depth 1 to leave out the history.
Again, you don't need to hack CMake configuration, just use this command to build QtWebKitNG:
That won't work because of QtTestBrowser, and I can't get it to install the libraries to the qtbase directory. It's ninja install.
There's also a mistake, it should be -DENABLE_OPENGL=NO
No needs to do that. Current master already includes the needed platform plugin that will be built on Linux.
Doesn't work, the build fails with cannot find -lqphantom.
The Makefile in the qt-qpa-platform-plugin directory doesn't seem to be doing anything.
Doesn't work, the build fails with cannot find -lqphantom.
@nkovacs you must use the latest version from the master branch.
I am using master.
Could you please post the output of qmake -r on a clean tree?
Info: creating stash file /home/nkovacs/progs/phantomjs2/phantomjs3/.qmake.stash
Reading /home/nkovacs/progs/phantomjs2/phantomjs3/src/qt-qpa-platform-plugin/phantom.pro
Info: creating stash file /home/nkovacs/progs/phantomjs2/phantomjs3/src/qt-qpa-platform-plugin/.qmake.stash
Reading /home/nkovacs/progs/phantomjs2/phantomjs3/src/phantomjs.pro
Project MESSAGE: Using Web Inspector resources from /home/nkovacs/progs/phantomjs2/webkit2/WebKitBuild/Release/DerivedSources/WebInspectorUI
Project MESSAGE: This project is using private headers and will therefore be tied to this specific Qt module build version.
Project MESSAGE: Running this project against other versions of the Qt modules may crash at any arbitrary point.
Project MESSAGE: This is not a bug, but a result of using Qt internals. You have been warned!
@nkovacs looks good. Now, can you post the output of make command? Thanks!
cd src/qt-qpa-platform-plugin/ && ( test -e Makefile.phantom || /home/nkovacs/progs/phantomjs2/qtbase2/bin/qmake /home/nkovacs/progs/phantomjs2/phantomjs3/src/qt-qpa-platform-plugin/phantom.pro -o Makefile.phantom ) && make -f Makefile.phantom
make[1]: Entering directory '/home/nkovacs/progs/phantomjs2/phantomjs3/src/qt-qpa-platform-plugin'
/home/nkovacs/progs/phantomjs2/qtbase2/bin/moc -DQT_NO_MTDEV -DQT_NO_LIBUDEV -DQT_NO_EVDEV -DQT_NO_TSLIB -DQT_NO_LIBINPUT -DQ_FONTCONFIGDATABASE -DQT_NO_EXCEPTIONS -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_NO_DEBUG -DQT_STATICPLUGIN -DQT_PLUGIN -DQT_PLATFORMSUPPORT_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_NO_GRAPHICSVIEW -DQT_NO_GRAPHICSEFFECT -DQT_NO_STYLESHEET -DQT_NO_STYLE_CDE -DQT_NO_STYLE_CLEANLOOKS -DQT_NO_STYLE_MOTIF -DQT_NO_STYLE_PLASTIQUE -DQT_NO_PRINTPREVIEWDIALOG -I/home/nkovacs/progs/phantomjs2/qtbase2/mkspecs/linux-g++ -I/home/nkovacs/progs/phantomjs2/phantomjs3/src/qt-qpa-platform-plugin -I/home/nkovacs/progs/phantomjs2/phantomjs3/src/qt-qpa-platform-plugin -I/home/nkovacs/progs/phantomjs2/qtbase2/include -I/home/nkovacs/progs/phantomjs2/qtbase2/include/QtPlatformSupport -I/home/nkovacs/progs/phantomjs2/qtbase2/include/QtPlatformSupport/5.7.1 -I/home/nkovacs/progs/phantomjs2/qtbase2/include/QtPlatformSupport/5.7.1/QtPlatformSupport -I/home/nkovacs/progs/phantomjs2/qtbase2/include/QtGui/5.7.1 -I/home/nkovacs/progs/phantomjs2/qtbase2/include/QtGui/5.7.1/QtGui -I/home/nkovacs/progs/phantomjs2/qtbase2/include/QtGui -I/home/nkovacs/progs/phantomjs2/qtbase2/include/QtCore/5.7.1 -I/home/nkovacs/progs/phantomjs2/qtbase2/include/QtCore/5.7.1/QtCore -I/home/nkovacs/progs/phantomjs2/qtbase2/include/QtCore -I/usr/include/c++/6 -I/usr/include/x86_64-linux-gnu/c++/6 -I/usr/include/c++/6/backward -I/usr/lib/gcc/x86_64-linux-gnu/6/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/6/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include main.cpp -o .moc/main.moc
g++ -c -pipe -O2 -fPIC -std=c++1z -fvisibility=hidden -fvisibility-inlines-hidden -fno-exceptions -Wall -W -Wvla -Wdate-time -D_REENTRANT -fPIC -DQT_NO_MTDEV -DQT_NO_LIBUDEV -DQT_NO_EVDEV -DQT_NO_TSLIB -DQT_NO_LIBINPUT -DQ_FONTCONFIGDATABASE -DQT_NO_EXCEPTIONS -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_NO_DEBUG -DQT_STATICPLUGIN -DQT_PLUGIN -DQT_PLATFORMSUPPORT_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_NO_GRAPHICSVIEW -DQT_NO_GRAPHICSEFFECT -DQT_NO_STYLESHEET -DQT_NO_STYLE_CDE -DQT_NO_STYLE_CLEANLOOKS -DQT_NO_STYLE_MOTIF -DQT_NO_STYLE_PLASTIQUE -DQT_NO_PRINTPREVIEWDIALOG -I. -I. -I/home/nkovacs/progs/phantomjs2/qtbase2/include -I/home/nkovacs/progs/phantomjs2/qtbase2/include/QtPlatformSupport -I/home/nkovacs/progs/phantomjs2/qtbase2/include/QtPlatformSupport/5.7.1 -I/home/nkovacs/progs/phantomjs2/qtbase2/include/QtPlatformSupport/5.7.1/QtPlatformSupport -I/home/nkovacs/progs/phantomjs2/qtbase2/include/QtGui/5.7.1 -I/home/nkovacs/progs/phantomjs2/qtbase2/include/QtGui/5.7.1/QtGui -I/home/nkovacs/progs/phantomjs2/qtbase2/include/QtGui -I/home/nkovacs/progs/phantomjs2/qtbase2/include/QtCore/5.7.1 -I/home/nkovacs/progs/phantomjs2/qtbase2/include/QtCore/5.7.1/QtCore -I/home/nkovacs/progs/phantomjs2/qtbase2/include/QtCore -I.moc -I/home/nkovacs/progs/phantomjs2/qtbase2/mkspecs/linux-g++ -o .obj/main.o main.cpp
g++ -c -pipe -O2 -fPIC -std=c++1z -fvisibility=hidden -fvisibility-inlines-hidden -fno-exceptions -Wall -W -Wvla -Wdate-time -D_REENTRANT -fPIC -DQT_NO_MTDEV -DQT_NO_LIBUDEV -DQT_NO_EVDEV -DQT_NO_TSLIB -DQT_NO_LIBINPUT -DQ_FONTCONFIGDATABASE -DQT_NO_EXCEPTIONS -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_NO_DEBUG -DQT_STATICPLUGIN -DQT_PLUGIN -DQT_PLATFORMSUPPORT_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_NO_GRAPHICSVIEW -DQT_NO_GRAPHICSEFFECT -DQT_NO_STYLESHEET -DQT_NO_STYLE_CDE -DQT_NO_STYLE_CLEANLOOKS -DQT_NO_STYLE_MOTIF -DQT_NO_STYLE_PLASTIQUE -DQT_NO_PRINTPREVIEWDIALOG -I. -I. -I/home/nkovacs/progs/phantomjs2/qtbase2/include -I/home/nkovacs/progs/phantomjs2/qtbase2/include/QtPlatformSupport -I/home/nkovacs/progs/phantomjs2/qtbase2/include/QtPlatformSupport/5.7.1 -I/home/nkovacs/progs/phantomjs2/qtbase2/include/QtPlatformSupport/5.7.1/QtPlatformSupport -I/home/nkovacs/progs/phantomjs2/qtbase2/include/QtGui/5.7.1 -I/home/nkovacs/progs/phantomjs2/qtbase2/include/QtGui/5.7.1/QtGui -I/home/nkovacs/progs/phantomjs2/qtbase2/include/QtGui -I/home/nkovacs/progs/phantomjs2/qtbase2/include/QtCore/5.7.1 -I/home/nkovacs/progs/phantomjs2/qtbase2/include/QtCore/5.7.1/QtCore -I/home/nkovacs/progs/phantomjs2/qtbase2/include/QtCore -I.moc -I/home/nkovacs/progs/phantomjs2/qtbase2/mkspecs/linux-g++ -o .obj/phantomintegration.o phantomintegration.cpp
g++ -c -pipe -O2 -fPIC -std=c++1z -fvisibility=hidden -fvisibility-inlines-hidden -fno-exceptions -Wall -W -Wvla -Wdate-time -D_REENTRANT -fPIC -DQT_NO_MTDEV -DQT_NO_LIBUDEV -DQT_NO_EVDEV -DQT_NO_TSLIB -DQT_NO_LIBINPUT -DQ_FONTCONFIGDATABASE -DQT_NO_EXCEPTIONS -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_NO_DEBUG -DQT_STATICPLUGIN -DQT_PLUGIN -DQT_PLATFORMSUPPORT_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_NO_GRAPHICSVIEW -DQT_NO_GRAPHICSEFFECT -DQT_NO_STYLESHEET -DQT_NO_STYLE_CDE -DQT_NO_STYLE_CLEANLOOKS -DQT_NO_STYLE_MOTIF -DQT_NO_STYLE_PLASTIQUE -DQT_NO_PRINTPREVIEWDIALOG -I. -I. -I/home/nkovacs/progs/phantomjs2/qtbase2/include -I/home/nkovacs/progs/phantomjs2/qtbase2/include/QtPlatformSupport -I/home/nkovacs/progs/phantomjs2/qtbase2/include/QtPlatformSupport/5.7.1 -I/home/nkovacs/progs/phantomjs2/qtbase2/include/QtPlatformSupport/5.7.1/QtPlatformSupport -I/home/nkovacs/progs/phantomjs2/qtbase2/include/QtGui/5.7.1 -I/home/nkovacs/progs/phantomjs2/qtbase2/include/QtGui/5.7.1/QtGui -I/home/nkovacs/progs/phantomjs2/qtbase2/include/QtGui -I/home/nkovacs/progs/phantomjs2/qtbase2/include/QtCore/5.7.1 -I/home/nkovacs/progs/phantomjs2/qtbase2/include/QtCore/5.7.1/QtCore -I/home/nkovacs/progs/phantomjs2/qtbase2/include/QtCore -I.moc -I/home/nkovacs/progs/phantomjs2/qtbase2/mkspecs/linux-g++ -o .obj/phantombackingstore.o phantombackingstore.cpp
rm -f /home/nkovacs/progs/phantomjs2/qtbase2/plugins/platforms/libqphantom.a
ar cqs /home/nkovacs/progs/phantomjs2/qtbase2/plugins/platforms/libqphantom.a .obj/main.o .obj/phantomintegration.o .obj/phantombackingstore.o
make[1]: Leaving directory '/home/nkovacs/progs/phantomjs2/phantomjs3/src/qt-qpa-platform-plugin'
It creates phantombackingstore.o, main.o and phantomintegration.o in .obj.
Edit: it does create libqphantom.a in /home/nkovacs/progs/phantomjs2/qtbase2/plugins/platforms/libqphantom.a, but ld can't find it when building phantomjs, because it's searching in the wrong place:
-L/home/nkovacs/progs/phantomjs2/phantomjs3/src/qt-qpa-platform-plugin/plugins/platforms
Also, add_definitions(-DQT_NO_GRAPHICSVIEW) is still needed for webkit, otherwise it builds libQt5WebKitWidgets.a with graphicsview, and it won't link.
No, I meant the full build log on a clean tree.
The previous binary had some problems, so I rebuilt it with some libraries built from sources.
Updated instructions:
export WORKDIR=some directory where you'll be building phantomjsapt-get source icucd icu*./configure --prefix="$WORKDIR"/icu-install --enable-static --disable-sharedmake && make install$WORKDIR/icu-install to pathsexport C_INCLUDE_PATH="$WORKDIR"/icu-install/include/export CPLUS_INCLUDE_PATH="$WORKDIR"/icu-install/include/export LIBRARY_PATH="$WORKDIR"/icu-install/libapt-get source libxml2cd libxml2-*./configure --prefix="$WORKDIR"/icu-install --enable-static --disable-shared --without-python --with-libxml-prefix="$WORKDIR/icu-install/"apt-get source libxsltapt-get source liblzma-ldl to the linker flags. See https://bugreports.qt.io/browse/QTBUG-58301./configure -static -release -prefix . -opensource -confirm-license -qpa phantom -openssl -openssl-linked -no-openvg -no-eglfs -no-egl -no-glib -no-gtk -no-cups -no-sm -no-xkb -no-xcb -no-kms -no-linuxfb -no-directfb -no-mirclient -no-mtdev -no-libudev -no-evdev -no-pulseaudio -no-alsa -no-feature-PRINTPREVIEWWIDGET -fontconfig -icu -nomake examples -nomake tools -nomake tests -no-qml-debug -no-dbus -no-opengl -no-audio-backend -D QT_NO_GRAPHICSVIEW -D QT_NO_GRAPHICSEFFECT -D QT_NO_STYLESHEET -D QT_NO_STYLE_CDE -D QT_NO_STYLE_CLEANLOOKS -D QT_NO_STYLE_MOTIF -D QT_NO_STYLE_PLASTIQUE -D QT_NO_PRINTPREVIEWDIALOG -no-pkg-config
add_definitions(-DQT_NO_GRAPHICSVIEW) under add_definitions(-DBUILDING_QT__=1)add_subdirectory(QtTestBrowser)./Tools/Scripts/build-webkit --qt --release --no-device-orientation --no-web-audio --no-video --no-video-track --no-touch-events --no-touch-slider --no-geolocation --no-netscape-plugin-api --64-bit --cmakeargs="-Wno-dev -DCMAKE_PREFIX_PATH=$WORKDIR/qtbase -DUSE_GSTREAMER=OFF -DUSE_THIN_ARCHIVES=OFF -DENABLE_API_TESTS=OFF -DENABLE_TEST_SUPPORT=OFF -DENABLE_OPENGL=OFF -DCMAKE_INSTALL_PREFIX=$WORKDIR/qtbase"cd WebKitBuild/Release && ninja install$WORKDIR/qtbase/bin/qmake && makemkdir -p src/qt-qpa-platform-plugin/plugins/platforms && cp $WORKDIR/qtbase/plugins/platforms/libphantom.* src/qt-qpa-plugin/plugins/platforms/-static-libstdc++ -static-libgcc to LFLAGSLIBS static by changing -lXXX to -l:libXXX.a. The order will also be incorrect, static libraries must come after their dependants. E.g. this works:LIBS = $(SUBLIBS) -L/home/nkovacs/progs/phantomjs2/phantomjs/src/qt-qpa-platform-plugin/plugins/platforms -lqphantom -L/home/nkovacs/progs/phantomjs2/qtbase/lib -lQt5WebKitWidgets -lQt5PrintSupport -lQt5Widgets -lQt5WebKit -lQt5PlatformSupport -lfontconfig -lfreetype -L/home/nkovacs/progs/phantomjs2/qtbase/plugins/imageformats -lqico -lQt5Gui -l:libjpeg.a -lqtharfbuzzng -L/home/nkovacs/progs/phantomjs2/qtbase/plugins/bearer -lqgenericbearer -lQt5Network -lssl -l:libcrypto.a -L/home/nkovacs/progs/phantomjs2/qtbase/plugins/sqldrivers -lqsqlite -lQt5Sql -lQt5Core -lz -l:libpcre16.a -lm -ldl -lrt -lpthread -lWebCore -lJavaScriptCore -licui18n -licuuc -licudata -lWTF -lxml2 -lbmalloc -lxslt -l:libhyphen.a -l:libwebp.a -lwoff2 -lbrotli -lfontconfig -lfreetype -llzma -l:libpng.a
This one now works in my docker image (nkovacs/selenium-standalone-phantomjs) as well as Debian Jessie: https://github.com/nkovacs/selenium-standalone-phantomjs/tree/11420aaf2174428b56086673232365c820f98a42
@nkovacs
I saw that you success in compiling phantomJS 2.5.0
Do you have a simple script to do that ... for linux at least..
Thank by advance
@Vitallium
I don't understand how it is so complex to compile source now... We aren't Qt and Webkit experts.
@nkovacs Thanks a ton for the detailed steps, I was able to get a static build working on SuSE linux by following your steps. The only change was in the Webkit compilation step where I had to pass -DCMAKE_PREFIX_PATH=$WORKDIR/icu-install instead of -DCMAKE_PREFIX_PATH=$WORKDIR/qtbase
A few places where I got tripped up:
*Cache.txt) before re-running the buildOther than that, everything seems to be working fine so far against a medium sized angular application. Fingers crossed that it stays that way.
@pixiuPL Are we continuing the development on phantomjs? I'm really glad to see some movement again. Thank you 馃憤
Due to our very limited maintenance capacity (see #14541 for more details), we need to prioritize our development focus on other tasks. Therefore, this issue will be closed. In the future, if we see the need to attend to this issue again, then it will be reopened.
Thank you for your contribution!
Most helpful comment
The previous binary had some problems, so I rebuilt it with some libraries built from sources.
Updated instructions:
export WORKDIR=some directory where you'll be building phantomjsapt-get source icucd icu*./configure --prefix="$WORKDIR"/icu-install --enable-static --disable-sharedmake && make install$WORKDIR/icu-installto pathsexport C_INCLUDE_PATH="$WORKDIR"/icu-install/include/export CPLUS_INCLUDE_PATH="$WORKDIR"/icu-install/include/export LIBRARY_PATH="$WORKDIR"/icu-install/libapt-get source libxml2cd libxml2-*./configure --prefix="$WORKDIR"/icu-install --enable-static --disable-shared --without-python --with-libxml-prefix="$WORKDIR/icu-install/"apt-get source libxsltapt-get source liblzma-ldlto the linker flags. See https://bugreports.qt.io/browse/QTBUG-58301./configure -static -release -prefix . -opensource -confirm-license -qpa phantom -openssl -openssl-linked -no-openvg -no-eglfs -no-egl -no-glib -no-gtk -no-cups -no-sm -no-xkb -no-xcb -no-kms -no-linuxfb -no-directfb -no-mirclient -no-mtdev -no-libudev -no-evdev -no-pulseaudio -no-alsa -no-feature-PRINTPREVIEWWIDGET -fontconfig -icu -nomake examples -nomake tools -nomake tests -no-qml-debug -no-dbus -no-opengl -no-audio-backend -D QT_NO_GRAPHICSVIEW -D QT_NO_GRAPHICSEFFECT -D QT_NO_STYLESHEET -D QT_NO_STYLE_CDE -D QT_NO_STYLE_CLEANLOOKS -D QT_NO_STYLE_MOTIF -D QT_NO_STYLE_PLASTIQUE -D QT_NO_PRINTPREVIEWDIALOG -no-pkg-configadd_definitions(-DQT_NO_GRAPHICSVIEW)underadd_definitions(-DBUILDING_QT__=1)add_subdirectory(QtTestBrowser)./Tools/Scripts/build-webkit --qt --release --no-device-orientation --no-web-audio --no-video --no-video-track --no-touch-events --no-touch-slider --no-geolocation --no-netscape-plugin-api --64-bit --cmakeargs="-Wno-dev -DCMAKE_PREFIX_PATH=$WORKDIR/qtbase -DUSE_GSTREAMER=OFF -DUSE_THIN_ARCHIVES=OFF -DENABLE_API_TESTS=OFF -DENABLE_TEST_SUPPORT=OFF -DENABLE_OPENGL=OFF -DCMAKE_INSTALL_PREFIX=$WORKDIR/qtbase"cd WebKitBuild/Release && ninja install$WORKDIR/qtbase/bin/qmake && makemkdir -p src/qt-qpa-platform-plugin/plugins/platforms && cp $WORKDIR/qtbase/plugins/platforms/libphantom.* src/qt-qpa-plugin/plugins/platforms/-static-libstdc++ -static-libgcctoLFLAGSLIBSstatic by changing-lXXXto-l:libXXX.a. The order will also be incorrect, static libraries must come after their dependants. E.g. this works:This one now works in my docker image (nkovacs/selenium-standalone-phantomjs) as well as Debian Jessie: https://github.com/nkovacs/selenium-standalone-phantomjs/tree/11420aaf2174428b56086673232365c820f98a42