Phantomjs: How to build master?

Created on 8 Nov 2016  路  30Comments  路  Source: ariya/phantomjs

Just a quick heads-up to let you know that building master has become very hard for newcomers due to lack of instructions since build.py was removed.

I tried the qmake && make commands as suggested, but it fails with the following error: Project ERROR: You must set the environment variable WEB_INSPECTOR_RESOURCES_DIR to generated Web Inspector resources. I have no idea how to get web inspector resources, googling doesn't help.

1. Which version of PhantomJS are you using?
Master branch.

2. What steps will reproduce the problem?

  1. Check out master branch
  2. Install dependencies: http://phantomjs.org/build.html
  3. qmake && make
  4. Project ERROR: You must set the environment variable WEB_INSPECTOR_RESOURCES_DIR to generated Web Inspector resources

3. Which operating system are you using?
Ubuntu GNOME 16.04

4. Did you use binary PhantomJS or did you compile it from source?
Source.

stale

Most helpful comment

Is there any draft version of the instructions available? I'll need to build the latest Version on Linux immediately. Also it would be great if the instruction would contain a description how to build with static libraries (ICU, ...). Thanks a lot!

All 30 comments

Yes, there is no step-by-step instruction right now. I am going to update it this week.

+1

Is there any draft version of the instructions available? I'll need to build the latest Version on Linux immediately. Also it would be great if the instruction would contain a description how to build with static libraries (ICU, ...). Thanks a lot!

You can start from building new QtWebKit - https://github.com/annulen/webkit/wiki
This is the most important part.

Any updates on the step-by-step to building master?

Thanks!

Hi @Vitallium, build and installation of QtWebKit is done. What's the next step?

+1

@markusschlebusch now just do a regular Qt project build. Keep in mind that if you installed QtWebKit in a different location you also need to set environment variable QMAKEPATH.

@Vitallium I already build qtwebkit follow the wiki, and install to /usr/local directory. After that i switch to phantomjs directory and run qmake && make, still not work. Is there some missing steps ?

@leeight please post the output of qmake && make

@Vitallium It works now. but after run bin/phantomjs, it crashed. I got a similar stacktrace like this issue: https://bugs.webkit.org/show_bug.cgi?id=158297

@Vitallium Thanks for update. I've the same issue reported inntially while executing qmake && make: Project ERROR: You must set the environment variable WEB_INSPECTOR_RESOURCES_DIR to generated Web Inspector resources

How can I fix this? Btw. where to geht WEB-Inspektor Resources?

WEB_INSPECTOR_RESOURCES_DIR - this option is required for static build only. Due to how the Qt resource system works you can't build static lib with resources (this will not work). Resources must be built against the executable file or a shared library.

If you use static build, you need to set this variable to:

export WEB_INSPECTOR_RESOURCES_DIR=YOUR_WEBKIT_BUILD_DIR/BUILD_TYPE/DerivedSources/WebInspectorUI

where:

  • YOUR_WEBKIT_BUILD_DIR - your WebKit build directory. If you didn't use the custom output dir, it would be like this: WEBKIT_SOURCE/WebKitBuild
  • BUILD_TYPE - Debug or Release

I will also push some improvements for build configuration today.

Thanks for this hint. Unfortunately this is the next error with qmake && make:
....
config.cpp:37:20: fatal error: QWebPage: No such file or directory
compilation terminated.

QWebPage was installed with the regular QtWebKit installation here:
/usr/local/include/QtWebKitWidgets/QWebPage

I assume this path is not in the INCLUDE in your Makefile. Can you please paste the command with which you built QtWebKit?

I build QtWebKit with this command:
WEBKIT_OUTPUTDIR=pwd/build/qt Tools/Scripts/build-webkit --qt --release --cmakeargs="-DCMAKE_PREFIX_PATH=/home/markus/Qt5.4.1/5.4/gcc_64"

Did you set QMAKEPATH variable before building PhantomJS?

Yes export QMAKEPATH=/home/markus/Qt5.4.1/5.4/gcc_64/bin

This is wrong. QMAKEPATH should point to the new QtWebKit root folder.
When you invoke qmake from /home/markus/Qt5.4.1/5.4/gcc_64/bin qmake knows about its modules, but it doesn't know anything about new QtWebKit. So you need to point to its mkspec.

You installed QtWebKit to /usr/local, so your QMAKEPATH will be export QMAKEPATH=/usr/local
Don't forget to clean the PhantomJS directory before building again :)
See here for more information about using new QtWebKit.

I've set export QMAKEPATH=/usr/local and cleaned the PhantomJS directory but it's still the same problem. Also the other option to create a .qmake.conf didn't change anything.

At the moment, the following code in src/phantomjs.pro is unconditional (lines 11-14):

WEB_INSPECTOR_RESOURCES_DIR = $$(WEB_INSPECTOR_RESOURCES_DIR)
isEmpty(WEB_INSPECTOR_RESOURCES_DIR): {
    error("You must set the environment variable WEB_INSPECTOR_RESOURCES_DIR to generated Web Inspector resources")
}

I saw that in @Vitallium's fork that this is moved inside the config(static) conditional: https://github.com/Vitallium/phantomjs/commit/16450bb919a0f5763651de39abc0ca2966ddae76

This may be why you're still unable to build PhantomJS.

@Qantas94Heavy exactly. PhantomJS 2.5 can be built with system (shared) Qt. That's why current condition is wrong.

I've invested much time to simply compile a current PhantomJS binary for Linux. Unfortunately it wasn't successful until now. Is there any nightly build or something else where I can get a binary?

@markusschlebusch I don't think there is, but I have managed to compile it on openSUSE -- you need to edit the file that I was referring to earlier.

It seems to requires Qt 5.6 or higher, as well as QtWebkit.

The minimum required version is 5.5. 5.6 is strongly advised for redirect signal. I decorated them with proper defines, so you can build PJS against 5.5 (or even 5.3 version). The main requirement for Linux build is GCC with C++11 support.

Any news on a way to build phantom.js? The documentation refers to a file that doesn't exist. The deploy folder can be successfully nuked because it's obsolete. There is no Makefile anywhere in the repo.
Any pointers?

@mishu- you have to edit the file I was referring to earlier, then run qmake-qt5 (or just qmake, depends on your system), then run make.

@mishu- I've just built using the fork from https://github.com/eisnerd/phantomjs, the standard instructions for building work just fine.

Here is the full process I used to build master on Ubuntu 16.04:

  1. Checkout phantom

  2. Install new Qt version. I followed these instructions for Ubuntu and installed Qt5.7 in my home directory

  3. Add the new Qt bin directory to your path, its something like /home/user/Qt5.7.0/5.7/gcc_64/bin. Verify you're using the right qmake w/ qmake --version.

  4. Build new webkit version. I got a zip file from github, since the repo is huge and takes forever to checkout. Make sure to specify your new Qt directory w/ -DCMAKE_PREFIX_PATH.

    You can also use https://github.com/annulen/qtwebkit-snapshots to avoid doing a git checkout.

  5. Set QMAKEPATH to /usr/local, run qmake && make in the phantom directory

    Make sure to run git clean -dxfq between qmake attempts to purge the old makefile!

Due to our very limited maintenance capacity, we need to prioritize our development focus on other tasks. Therefore, this issue will be automatically closed (see #15395 for more details). In the future, if we see the need to attend to this issue again, then it will be reopened. Thank you for your contribution!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yairza picture yairza  路  6Comments

Snowlav picture Snowlav  路  3Comments

bhuvnesh2703 picture bhuvnesh2703  路  3Comments

h4wlt picture h4wlt  路  5Comments

yisibl picture yisibl  路  5Comments