deanmao / node-chimera

A new kind of headless webkit integration for nodejs; a great alternative to phantomjs.
http://www.deanmao.com/2012/08/13/enter-chimera/
MIT License
847 stars 45 forks source link

Building on Ubuntu x64 #34

Open dhendo opened 11 years ago

dhendo commented 11 years ago

I'm trying to build on Ubuntu 12.04 so that I can start to poke around with the binding and test some changes.

Steps Taken:

This fails:

platform/qt/WheelEventQt.cpp: In constructor ‘WebCore::PlatformWheelEvent::PlatformWheelEvent(QGraphicsSceneWheelEvent*)’:
platform/qt/WheelEventQt.cpp:62:19: error: invalid use of incomplete type ‘struct QGraphicsSceneWheelEvent’
platform/PlatformWheelEvent.h:42:7: error: forward declaration of ‘struct QGraphicsSceneWheelEvent’
platform/qt/WheelEventQt.cpp:63:25: error: invalid use of incomplete type ‘struct QGraphicsSceneWheelEvent’
platform/PlatformWheelEvent.h:42:7: error: forward declaration of ‘struct QGraphicsSceneWheelEvent’
platform/qt/WheelEventQt.cpp:66:19: error: invalid use of incomplete type ‘struct QGraphicsSceneWheelEvent’
platform/PlatformWheelEvent.h:42:7: error: forward declaration of ‘struct QGraphicsSceneWheelEvent’
platform/qt/WheelEventQt.cpp:67:18: error: invalid use of incomplete type ‘struct QGraphicsSceneWheelEvent’
platform/PlatformWheelEvent.h:42:7: error: forward declaration of ‘struct QGraphicsSceneWheelEvent’
platform/qt/WheelEventQt.cpp:68:17: error: invalid use of incomplete type ‘struct QGraphicsSceneWheelEvent’
platform/PlatformWheelEvent.h:42:7: error: forward declaration of ‘struct QGraphicsSceneWheelEvent’
platform/qt/WheelEventQt.cpp:69:18: error: invalid use of incomplete type ‘struct QGraphicsSceneWheelEvent’
platform/PlatformWheelEvent.h:42:7: error: forward declaration of ‘struct QGraphicsSceneWheelEvent’
platform/qt/WheelEventQt.cpp:73:17: error: invalid use of incomplete type ‘struct QGraphicsSceneWheelEvent’
platform/PlatformWheelEvent.h:42:7: error: forward declaration of ‘struct QGraphicsSceneWheelEvent’
platform/qt/WheelEventQt.cpp:73:29: error: invalid use of incomplete type ‘struct QGraphicsSceneWheelEvent’
platform/PlatformWheelEvent.h:42:7: error: forward declaration of ‘struct QGraphicsSceneWheelEvent’
make: *** [.obj/release-static/WheelEventQt.o] Error 1

This results in libQtWebKit.a not being available for the compile_binary step.

I've had the same issue on an 11.04 and 12.04 machine (the second installed from scratch).

Any ideas?

I'll try with qt 5.0.1 as well shortly.

dhendo commented 11 years ago

5.0.1 didn't work either - looks like it would need a re-worked compile_qt.sh as the flags appear to have changed.

dhendo commented 11 years ago

Any ideas @deanmao ?

dlau commented 11 years ago

@dhendo, recently built this, looks like most of the qt build stuff came from phantomjs.

Try checking out phantomjs at ariya/phantomjs, then put that qt directory in the node-chimera root dir. The build scripts should work fine, else you can use the preconfig.sh file included with phantomjs and shift some files around.

I also had to compile the qt style sheets, so I removed the preprocessor directives for those in the compile_qt.sh

dhendo commented 11 years ago

@dlau Thanks - I'll give that a try and report back

dhendo commented 11 years ago

@dlau Right, I think I got there - in the end.

I'm now in the position seen in #26 - I now look to be getting errors at the node/binding level rather than Segfaulting

For future reference, all the changes I made are in: dhendo/node-chimera@3b00a5a689ff6617255899bf81360f204ed8d36e

ak5 commented 11 years ago

@dhendo did you get this to work? I am still having trouble both trying to use the chimera.node I get when running npm install chimera or compiling my own.

dhendo commented 11 years ago

@alexanderververis Nope - I got what I think is a correctly compiled and linked Qt, OpenSSL and binding, but still get undefined symbol: _ZNK9QMimeData10metaObjectEv when I try run against node 0.10.4

I did spot a new Python based project that is built using Qt5 recently - https://news.ycombinator.com/item?id=5742470 - maybe it would be worth looking into building against Qt5 going forwards?

ak5 commented 11 years ago

Did you incorporate this patch? https://github.com/deanmao/node-chimera/pull/32

dhendo commented 11 years ago

Yes, the uv_after_work_cb cast is in https://github.com/dhendo/node-chimera/commit/3b00a5a689ff6617255899bf81360f204ed8d36e

cjpartridgeb commented 11 years ago

@dhendo Thanks for the info regarding compiling on linux, your advice mixed with some other changes got me a working build on Ubuntu 12.04 and node 0.8.x - did you have it working under 0.8.x? I will rebuild under 0.10.x this evening and report back.

dhendo commented 11 years ago

@cjpartridgeb No, I never got it working under 0.8.x either. What extra steps did you take to the ones I outlined + forked?

cjpartridgeb commented 11 years ago

@dhendo Tested on 0.10 last night with the changes you specified in https://github.com/dhendo/node-chimera/commit/3b00a5a689ff6617255899bf81360f204ed8d36e - working binary as well.

I've put my changes here https://gist.github.com/cjpartridgeb/5702641 for the time being, as I don't have git on this machine.

dhendo commented 11 years ago

Thanks, I'll give it a go in a clean VM and see how I get on.

dhendo commented 11 years ago

Great - it now builds happily on 12.04 - it looks like the major change was to build qt as x86?

I've got the updates in https://github.com/dhendo/node-chimera

Hopefully now I can fiddle with the binding, and expose more useful bits and pieces (hopefully making it possible to render a string of html to an image returned in a byte array that can be returned directly by node)

cjpartridgeb commented 11 years ago

Glad to hear @dhendo .

I think the main issue was just specifying the correct linking options in the compile_binary.sh script. As when I ran "ldd -r chimera.node" it would show undefined symbols relating to openssl (there were also a bunch for gstreamer and other qt feature dependencies, which are opted out off in the qt configure - so I assume they are safe to ignore).

I'm working on some more robust PDF printing features as we speak, but it appears the standard Qt still has issues that were seen with wkhtmltopdf (https://code.google.com/p/webkit-mirror) - at least from initial inspection.

dhendo commented 11 years ago

@cjpartridgeb I've made some changes in my fork:

https://github.com/dhendo/node-chimera/commit/233c7158b39360e42fdbecd1552bb4f7d2c0f8a3

cjpartridgeb commented 11 years ago

@dhendo awesome stuff - having a browse through your changes now.

In regards to your first note (render directly back to a node Buffer), can you see a way this is possible for the PDF printing? Not being very adept with C++, I'm having trouble seeing how a QPainter would be able to achieve this.

dhendo commented 11 years ago

@cjpartridgeb My C++ isn't great either! It may be possible, although it looks like QPrinter will only take a filename, and won't save to a QIODevice like QImage can. Bug report: https://bugreports.qt-project.org/browse/QTBUG-3510

One way to do it would be to save to file, then immediately load the file into a QByteArray and return that. That would at least save reading the file again in node.

cjpartridgeb commented 11 years ago

@dhendo I tried sending to "/dev/stdout" and it pumps it straight out of stdout - I guess this would be helpful for a cli utility. However, I'm wondering if there's a way to write to a custom file descriptor and read it back into a byte array/buffer without actually touching disk - will keep investigating

dhendo commented 11 years ago

@cjpartridgeb Hmm.. would probably have to be something cross-platform?

ak5 commented 11 years ago

Hi guys!

I am trying to replicate what you are doing, but I seem to have an error when calling the compile_binary.sh script.

It seems qt didn't compile correctly:

g++: error: ../qt_compiled/lib/libQtWebKit.a: No such file or directory
g++: error: ../qt_compiled/lib/libwebcore.a: No such file or directory

See this gist for the full output: https://gist.github.com/alexanderververis/315ac2624cb9ff9fda67

cjpartridgeb commented 11 years ago

@alexanderververis

I'd suggest using dhendo's repository, otherwise take a look at my gist above - it has the exact instructions I've used to compile on several Ubuntu based machines.

dhendo commented 11 years ago

@alexanderververis Looks like qt didn't build quite right.

As @cjpartridgeb said, try my branch (clean everything down first) Pay attention to what happens near the end of compile_qt.sh - it links some bits of qt into the qt_compiled directory:

https://github.com/dhendo/node-chimera/blob/master/scripts/compile_qt.sh#L132

dhendo commented 11 years ago

Link to a (hopefully) working binary. Compiled on Ubuntu 12.04. May or may not contain the rendering tweaks - I'll get a more recent build up sometime.

https://s3.amazonaws.com/node-chimera-binary/node-chimera-ununtu-12.04-2013-06-13.zip

ak5 commented 11 years ago

Thanks @dhendo this works well!

krakatoa commented 11 years ago

Sorry @dhendo just to catch up, I don't understand what has to be working on the master branch. I still have the issue with libQtWebKit.a, and libfontconfig is missing too. To recap, do you still recommend using the phantomjs build mentioned earlier ?

ak5 commented 11 years ago

@krakatoa I also had issues with libQtWebKit.a but I am currently getting away with using his binary linked above and 'npm install chimera'

dhendo commented 11 years ago

@krakatoa Yes, download the phantom source and copy the qt folder to the chimera/qt.

krakatoa commented 11 years ago

Great @dhendo, thanks! I will try it ;)

krakatoa commented 11 years ago

@alexanderververis I was all yesterday's afternoon and night trying to link it, now I want to finish that haha ! anyway, thank you too

deanmao commented 11 years ago

Sorry for being late to the party, but hopefully these issues will go away soon. I'm currently moving chimera to Qt5, but many APIs have changed since Qt4, but the good part is that the build process is significantly improved. QPA is standard in Qt5 so the crazy build process may or may not be necessary if you already have Qt5 installed. I'll probably still include the Qt5 as a submodule for systems that may need to build from scratch (like on the mac) due to openssl incompatibilities in nodejs vs qt.

cjpartridgeb commented 11 years ago

@deanmao Great news, look forward to hacking on the Qt5 version! Thanks for all your hard work

dhendo commented 11 years ago

@deanmao Awesome - let me know if there is anything I can do

krakatoa commented 11 years ago

Same here @deanmao ! hey @dhendo that worked perfectly, a small step missing was to delete ./openssl/test file before compiling.. now I can start testing chimera :+1:

deanmao commented 11 years ago

I finished porting it to Qt5, however I will have to think of a new way of packaging/deployment because I could only do a shared library implementation, and thus one would require external Qt5 libraries. For some people, it may be problematic if they run this on heroku or another service that doesn't have Qt5 installed on the system. Building chimera is a lot easier now though.

I'll push my stuff once I figure out what's the best way to deploy this stuff for everyone.

dhendo commented 11 years ago

@deanmao Great stuff. Personally, I think I'd be OK with a shared lib implementation - will be using in an environment controlled by Chef, so should be able to get all requirements in place.

I understand that it may be trickier for others to do so on shared platforms.

let me know when you have something I can test out.

deanmao commented 11 years ago

Sure thing. It works great in linux, but I'm building it for osx right now, when that's done I'll package it up and do a npm publish so you all can test.

cjpartridgeb commented 11 years ago

@deanmao That was quick, good stuff!

dhendo commented 11 years ago

Hi @deanmao - got anything for us yet? I'm running into callback issues in the current version, and it's probably wort trying int he new version before getting too much deeper into this.

deanmao commented 11 years ago

I guess I could fork it into 2 versions -- at the moment, the new version requires qt5 to be installed on the system, which would be a show-stopper for those running node on joyent or heroku since they would need a custom AMI with qt5 installed.

dhendo commented 11 years ago

That'd be great - a github branch or something. I'm currently debugging the some async work/callback issues with the renderSnippet methods I wrote - so being able to wrok against the new code would be a bonus.

deanmao commented 11 years ago

Sorry about the delay guys. I pushed my branch of the 5.0 stuff -- the downside is that static linking won't work anymore, it's due to a large number of issues, but if you look at the configure script written by the qt people, they explicitly prevent static linking in webkit, probably due to licensing issues. However, if the dynamic linked version works fine, as long as you do the build yourself.

dhendo commented 11 years ago

Cool - I'll try get the build working against Ubuntu and report back.

tpickett commented 10 years ago

@dhendo, did you ever get qt5 working correctly? I have qt4.8 working, but i can't get the thing to click and follow links. don't know if this is a qt issue or if its a chimera issue...

dhendo commented 10 years ago

@tpickett Sorry - no, I haven't had time to bang my head against it lately! Did you try @deanmao 's qt5.0 branch?

tpickett commented 10 years ago

yeah i couldn't get it or the 4.8 to compile correctly. your binary was the only one i could get working in Ubuntu.