wiki:BuildingQtOnOSX

Version 8 (modified by piet.webkit@yahoo.com, 11 years ago) (diff)

Require qt4-mac-dev (v4.6) instead of qt4-mac (v4.5.3). See https://bugs.webkit.org/show_bug.cgi?id=32216.

See Also:

These instructions assume you are building on an OSX system with Mac Ports installed having the qt4-mac-devel (4.6) port installed.

Checkout the Code

You'll need to check out WebKit from SVN or Qt WebKit from Git

svn checkout http://svn.webkit.org/repository/webkit/trunk WebKit # WebKit SVN Trunk

OR

git clone git://gitorious.org/webkit/webkit.git # Git mirror

Building

Workaround #1 - for missing Qt Headers

This works around the problem with Qt headers being reference directly from /usr/include regardless of where the QTDIR is (Fixes "../../../WebKit/JavaScriptCore/wtf/unicode/qt4/UnicodeQt4.h:26:17: error: QChar: No such file or directory" errors):

export QTDIR=/opt/local/libexec/qt4-mac-devel # mac ports Qt
cd /usr/include
for q in $QTDIR/include/*; do if [ ! -e "`basename $q`" ]; then sudo ln -s "$q"; fi ; done # create a symlink

Workaround #2 - for flex tokenizer.cpp generation problem

Next start the build:

export WEBKITSRCDIR=qtwebkit # change this to 'WebKit' to build WebKit SVN Trunk
export WEBKITOUTPUTDIR=`pwd`/${WEBKITSRCDIR}-build 
${WEBKITSRCDIR}/WebKitTools/Scripts/build-webkit --qt --qmake=qmake-4.5 --makeargs="-j2" -spec macx-g++ --no-video --debug # change 'qmake-4.5' to '/opt/local/libexec/qt4-mac-devel/bin/qmake' if installed from Mac Ports

The build will ultimately fail with an error message "Undefined symbols: "WebCore::CSSParser::lex()", referenced from: WebCore::CSSParser::lex(void*)in CSSParser.o" when it attempts to link the binaries, to fix that we run the flex make target by hand and copy the result into the build output drectory:

cd ${WEBKITSRCDIR}/WebCore
rm tokenizer.cpp 
WebCore=. make -f DerivedSources.make tokenizer.cpp
mv tokenizer.cpp ${WEBKITOUTPUTDIR}/Debug/WebCore/generated/debug/tokenizer.cpp
cd ${WEBKITSRCDIR}/..

Finish Up and Run

Rerunning the build should recompile CSSParser.cpp and link correctly.

${WEBKITSRCDIR}/WebKitTools/Scripts/build-webkit --qt --qmake=qmake-4.5 --makeargs="-j2" -spec macx-g++ --no-video --debug

Finally start the demo Qt browser:

${WEBKITSRCDIR}/WebKitTools/Scripts/run-launcher --qt --debug # After this, check the dock and you'll see an icon for a Qt console app ...