node-chimera icon indicating copy to clipboard operation
node-chimera copied to clipboard

Building on Ubuntu x64

Open dhendo opened this issue 11 years ago • 46 comments

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:

  • Cloned the Repo
  • Untar http://releases.qt-project.org/qt4/source/qt-everywhere-opensource-src-4.8.4.tar.gz into ./qt
  • run ./scripts/compile_openssl.sh - OK
  • run ./scripts/compile_qt

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 avatar Apr 04 '13 12:04 dhendo

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 avatar Apr 08 '13 15:04 dhendo

Any ideas @deanmao ?

dhendo avatar Apr 24 '13 10:04 dhendo

@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

dlau avatar May 09 '13 08:05 dlau

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

dhendo avatar May 09 '13 16:05 dhendo

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

  • I ended up using a modified version of preconfig.sh, with bits taken from compile_qt.sh. I couldn't get the prefix to work, so ended up copying files.
  • Getting OpenSSL to link statically was a pain. I had to mess around with the linker options in compile_binary.sh until it didn't segfault. (Hint for anyone following - running example.js under gdb is useful: "gdb node" followed by "run example.js" when it segfaults type "bt" + enter. This will show the backtrace.)
  • libfontconfig wasn't in the place that compile_binary.sh was expecting.

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

dhendo avatar May 14 '13 08:05 dhendo

@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.

ak5 avatar Jun 01 '13 09:06 ak5

@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?

dhendo avatar Jun 01 '13 09:06 dhendo

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

ak5 avatar Jun 01 '13 09:06 ak5

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

dhendo avatar Jun 01 '13 09:06 dhendo

@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.

cjpartridgeb avatar Jun 03 '13 01:06 cjpartridgeb

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

dhendo avatar Jun 03 '13 11:06 dhendo

@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.

cjpartridgeb avatar Jun 04 '13 00:06 cjpartridgeb

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

dhendo avatar Jun 04 '13 07:06 dhendo

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)

dhendo avatar Jun 04 '13 10:06 dhendo

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.

cjpartridgeb avatar Jun 04 '13 13:06 cjpartridgeb

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

  • Allow chimera to render directly back to a node Buffer to allow node to server up a response without writing to then reading from the filesystem.
  • Allow an arbitrary html snippet to be rendered without needing to request it over the network
  • Enable chimera to clip the rendered image to an element using a selector
  • Ported rendering code from PhantomJS with a fix for rendering large images

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

dhendo avatar Jun 05 '13 09:06 dhendo

@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.

cjpartridgeb avatar Jun 05 '13 10:06 cjpartridgeb

@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.

dhendo avatar Jun 05 '13 10:06 dhendo

@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

cjpartridgeb avatar Jun 06 '13 00:06 cjpartridgeb

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

dhendo avatar Jun 07 '13 20:06 dhendo

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

ak5 avatar Jun 12 '13 11:06 ak5

@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.

cjpartridgeb avatar Jun 13 '13 03:06 cjpartridgeb

@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 avatar Jun 13 '13 13:06 dhendo

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

dhendo avatar Jun 13 '13 14:06 dhendo

Thanks @dhendo this works well!

ak5 avatar Jun 18 '13 06:06 ak5

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 ?

krakatoa avatar Jun 18 '13 12:06 krakatoa

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

ak5 avatar Jun 18 '13 12:06 ak5

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

  • libQTWebkit.a I think was a tweak to the qt compile script: https://github.com/dhendo/node-chimera/blob/master/scripts/compile_qt.sh#L132
  • libfontconfig - was due to a different path in the linker: https://github.com/dhendo/node-chimera/blob/master/scripts/compile_binary.sh#L9

dhendo avatar Jun 18 '13 12:06 dhendo

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

krakatoa avatar Jun 18 '13 12:06 krakatoa

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

krakatoa avatar Jun 18 '13 12:06 krakatoa