Tutorial on Compiling Qt


eyecreate

Member
Joined
Feb 3, 2009
Messages
253
Website
git.eyecreate.org
Backstory:

So, this all started when I kept finding issues preventing me from getting a working kdelibs. I last tried getting sebt3's kdelibs from his kdegames package, but was missing some includes and kde.org didn't supply the exact version of kdelibs he was using anymore plus something fancy about missing some hidden switch in Qt. I got frustrated and decided maybe it'd be best if I just learned how to do it myself. Many hours later, I got results and decided it'd be best to share so if someone else got in a pickle like me, they'd have a Fancy Bible of Qt Compilation Steps(kinda)


My face before starting:


ZXJ0k.png


Ok, so here is my steps needed to get a working Qt build for the pandora(I was building 4.7.4).


Required items:


AB3BM.png




Step 1:


Download the source, luke.


You can find it here:


http://qt.nokia.com/downloads/


but the links you want were trickily made the smallest.


9XeQU.png



Make sure to find a way to bring these into the VM. I happened to set up a shared folder.(Or, you could be cool and just download it inside the VM)


Step 2:


There's nothing like homemade soup to cure what ails you


Reasons for parts of this step:

So, yactfeau is pretty handy to have around. It's set up as a normal ubuntu install but with the pandora sdk tools set in it's own dir nearby. The helper scripts that are usable hide the main system from the compiling apps so they think the pandora sdk tools ARE the host compilation tools making little changes to the program's compilation routine. Problems start cropping up when a program's compilation routine expects it's "room" to be tidied up a certain way. For the longest time, I fought with Qt only to realise the important truth...Qt isn't supposed to be run through yactfeau's build system. This creates some fancy inception-like thing where it can't tell if it's in a "dream" or not and thinks the fake world is real and "goes deeper" to create more fake cross-compile setups. So, short story, run Qt's compilation as normal environment, you can set up Qt's mkspec(files to describe how Qt wants it's environment set up.) files to work similarly to what yactfeau's setprj does.


disclaimer: I am in no way able to know what compilation options would actually work best and optimal. I mearly made sure it compiled.


Now comes the setup. First, make sure you have some yactfeau folders set up so the qt build goes somewhere when done. I made one called kdelibs(/mnt/utmp/kdelibs , ~/Pandora/kdelibs) and extracted qt into a folder there.(henceforth called QTSOURCE)


Next, find the mkspec that is used for the pandora normally and copy it to QTSOURCE/mkspecs. This folder should exist in /usr/local/angstrom/arm/share/qt4/mkspecs as linux-pandora-g++.


We're gona modify the heck outa the qmake.conf file in there.


So, let's open that qmake.conf sucker and make it work outside the yactfeau environment. Here's what I have, with spots for you to fill in.

MAKEFILE_GENERATOR = UNIX


QT += core gui


QT_ARCH = armv6


CONFIG += qt warn_on release incremental link_prl


DEFINES += QT_DEFAULT_TEXTURE_GLYPH_CACHE_WIDTH=1024 QT_GL_NO_SCISSOR_TEST


PREFIX = /mnt/utmp/kdelibs <- put in your directory to output to


QMAKE_CHK_DIR_EXISTS = test -d


QMAKE_COPY = cp -f


QMAKE_COPY_DIR = $(COPY) -r


QMAKE_COPY_FILE = $(COPY)


QMAKE_MKDIR = mkdir -p


QMAKE_MOVE = mv -f


QMAKE_DEL_DIR = rmdir


QMAKE_DEL_FILE = rm -f


QMAKE_GZIP = gzip -9f


QMAKE_TAR = tar -cf


QMAKE_INSTALL_FILE = install -m 644 -p


QMAKE_INSTALL_PROGRAM = install -m 755 -p


QMAKE_LEXFLAGS +=


QMAKE_LEX = flex


QMAKE_YACCFLAGS += -d


QMAKE_YACCFLAGS_MANGLE += -p $base -b $base


QMAKE_YACC_HEADER = $base.tab.h


QMAKE_YACC_SOURCE = $base.tab.c


QMAKE_YACC = yacc


QT_INSTALL_BINS = $HOME/Projects/Pandora/kdelibs/bin


QMAKE_MOC = $$[QT_INSTALL_BINS]/moc


QMAKE_RCC = $$[QT_INSTALL_BINS]/rcc


QMAKE_UIC = $$[QT_INSTALL_BINS]/uic


QMAKE_AR = /usr/local/angstrom/arm/bin/arm-angstrom-linux-gnueabi-ar cqs


QMAKE_CC = /usr/local/angstrom/arm/bin/arm-angstrom-linux-gnueabi-gcc


QMAKE_CXX = /usr/local/angstrom/arm/bin/arm-angstrom-linux-gnueabi-g++


QMAKE_LINK_C_SHLIB = $$QMAKE_CC


QMAKE_LINK_C = $$QMAKE_CC


QMAKE_LINK_SHLIB = $$QMAKE_CXX


QMAKE_LINK = $$QMAKE_CXX


QMAKE_STRIP = /usr/local/angstrom/arm/bin/arm-angstrom-linux-gnueabi-strip


QMAKE_CFLAGS_DEPS += -M


QMAKE_CFLAGS += -pipe


QMAKE_CFLAGS_RELEASE += -fno-omit-frame-pointer -fno-optimize-sibling-calls


QMAKE_CFLAGS_RELEASE += -DPANDORA -DHAVE_GLES -O3 -pipe -march=armv7-a -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp -ftree-vectorize -fsingle-precision-constant -fsigned-char <- no fast math due to sqlite


QMAKE_CFLAGS_SHLIB += -fPIC


QMAKE_CFLAGS_STATIC_LIB += -fPIC


QMAKE_CFLAGS_THREAD += -D_REENTRANT


QMAKE_CFLAGS_WARN_OFF += -w


QMAKE_CFLAGS_WARN_ON += -Wall -W


QMAKE_CFLAGS_YACC += -Wno-unused -Wno-parentheses


QMAKE_CXXFLAGS_DEBUG += $$QMAKE_CFLAGS_DEBUG


QMAKE_CXXFLAGS_DEPS += $$QMAKE_CFLAGS_DEPS


QMAKE_CFLAGS_HIDESYMS += -fvisibility=hidden <- un commented because I got errors with other Qt compilations about this not being set.


#QMAKE_CXXFLAGS_HIDESYMS += $$QMAKE_CFLAGS_HIDESYMS -fvisibility-inlines-hidden


QMAKE_CXXFLAGS += $$QMAKE_CFLAGS


QMAKE_CXXFLAGS_RELEASE += -fno-omit-frame-pointer -fno-optimize-sibling-calls


QMAKE_CXXFLAGS_RELEASE += $$QMAKE_CFLAGS_RELEASE


QMAKE_CXXFLAGS_SHLIB += $$QMAKE_CFLAGS_SHLIB


QMAKE_CXXFLAGS_STATIC_LIB += $$QMAKE_CFLAGS_STATIC_LIB


QMAKE_CXXFLAGS_THREAD += $$QMAKE_CFLAGS_THREAD


QMAKE_CXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE


QMAKE_CXXFLAGS_WARN_OFF += $$QMAKE_CFLAGS_WARN_OFF


QMAKE_CXXFLAGS_WARN_ON += $$QMAKE_CFLAGS_WARN_ON


QMAKE_CXXFLAGS_YACC += $$QMAKE_CFLAGS_YACC


QMAKE_INCDIR = /usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/usr/include


QMAKE_INCDIR_OPENGL = /usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/usr/include


QMAKE_INCDIR_OPENGL_ES1CL = /usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/usr/include


QMAKE_INCDIR_OPENGL_ES1 = /usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/usr/include


QMAKE_INCDIR_OPENGL_ES2 = /usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/usr/include


QMAKE_INCDIR_EGL = /usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/usr/include


QMAKE_INCDIR_OPENVG = /usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/usr/include/VG


QMAKE_INCDIR_QT = /mnt/utmp/kdelib/include/qt4 <- same as above, use your own output dir


QMAKE_INCDIR_X11 = /usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/usr/include/X11


QMAKE_INCREMENTAL_STYLE = sublib


QMAKE_LFLAGS += -L/media/PandoraDevel/Pandora/kdelibs/qt-everywhere-opensource-src-4.7.4/lib -L/mnt/utmp/kdelibs/lib -L/usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/usr/lib -Wl,-rpath,/usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/usr/lib <- pretty important, this was modified from yactfeau settings so that the first dir to link from was it's own libs. It tried using libs from qt 4.6 to link before, so put the QTSOURCE/lib dir here.


QMAKE_LFLAGS_APP +=


QMAKE_LFLAGS_BSYMBOLIC_FUNC = -Wl,-Bsymbolic-functions


QMAKE_LFLAGS_DEBUG +=


QMAKE_LFLAGS_DYNAMIC_LIST = -Wl,--dynamic-list,


QMAKE_LFLAGS_NOUNDEF += -Wl,--no-undefined


QMAKE_LFLAGS_RELEASE += -Wl,-O2


QMAKE_LFLAGS_SHLIB += -shared


QMAKE_LFLAGS_PLUGIN += $$QMAKE_LFLAGS_SHLIB


QMAKE_LFLAGS_SONAME += -Wl,-soname,


QMAKE_LFLAGS_THREAD +=


QMAKE_LIBDIR = /usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/usr/lib


QMAKE_LIBDIR_OPENGL = /usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/usr/lib


QMAKE_LIBDIR_OPENGL_ES1CL = $$QMAKE_LIBDIR_OPENGL


QMAKE_LIBDIR_OPENGL_ES1 = $$QMAKE_LIBDIR_OPENGL


QMAKE_LIBDIR_OPENGL_ES2 = $$QMAKE_LIBDIR_OPENGL


QMAKE_LIBDIR_EGL = /usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/usr/lib


QMAKE_LIBDIR_OPENVG =


QMAKE_LIBDIR_QT = /mnt/utmp/panorama/lib


QMAKE_LIBDIR_X11 = /usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/usr/lib


QMAKE_LIBS =


QMAKE_LIBS_DYNLOAD = -ldl


QMAKE_LIBS_EGL = -lEGL


QMAKE_LIBS_NIS = -lnsl


QMAKE_LIBS_OPENGL_ES1CL = -lGLES_CL


QMAKE_LIBS_OPENGL_ES1 = -lGLES_CM


QMAKE_LIBS_OPENGL_ES2 = -lGLESv2


QMAKE_LIBS_OPENGL = -lGLES_CM


QMAKE_LIBS_OPENGL_QT = -lGL


QMAKE_LIBS_OPENVG = -lOpenVG


QMAKE_LIBS_THREAD = -lpthread


QMAKE_LIBS_X11 = -lXext -lX11 -lm


QMAKE_LIBS_X11SM = -lSM -lICE


QMAKE_OBJCOPY = objcopy


QMAKE_PCH_OUTPUT_EXT = .gch


QMAKE_CFLAGS_PRECOMPILE += -x c-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT}


QMAKE_CFLAGS_USE_PRECOMPILE += -include ${QMAKE_PCH_OUTPUT_BASE}


QMAKE_CXXFLAGS_PRECOMPILE += -x c++-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT}


QMAKE_RANLIB =


QMAKE_LFLAGS_RPATH = -Wl,-rpath,


QMAKE_STRIPFLAGS_LIB += --strip-unneeded


TEMPLATE = app


QMAKE_PREFIX_STATICLIB = lib


QMAKE_EXTENSION_STATICLIB = a


load(qt_config)


Also, I had some small modifications to the qt 4.7.4 source specifically related to doubles:

qsvgtinydocument.cpp:468


double runningPercentage = qMin(m_time.elapsed()/double(m_animationDuration), double(1.));


CSSParser.cpp:3604


colorArray[3] = static_cast<int>(max(double(0.0), min(double(1.0), v->fValue)) * nextafter(256.0, 0.0));


CSSParser.cpp:3630


colorArray = max(double(0.0), min(double(100.0), v->fValue)) / 100.0; // needs to be value between 0 and 1.0


CSSParser.cpp:3639


colorArray[3] = max(double(0.0), min(double(1.0), v->fValue));


CSSPrimitiveValue.cpp:491


zoomedResult = max(double(1.0), zoomedResult);


HTMLInputElement.cpp:641


parsed = max(round(parsed), double(1.0));


HTMLInputElement.cpp:645


result = max(round(result), double(1.0));


CachedResource.cpp:132


double apparentAge = isfinite(dateValue) ? max(double(0.), m_responseTimestamp - dateValue) : 0;


AnimationBase.cpp:1131


elapsedDuration = max(elapsedDuration, double(0.0));


AnimationBase.cpp:1172


return max(timeFromNow, double(0.0));


AnimationBase.cpp:1232


const double elapsedDuration = max(beginAnimationUpdateTime() - m_startTime, double(0.0));


FrameView.cpp:1248


return max(double(0.), m_deferredRepaintDelay - timeSinceLastPaint);


BitmapImage.cpp:315


m_frameTimer->startOneShot(std::max(m_desiredFrameStartTime - time, double(0.)));


SVGRenderTreeAsText.cpp:313


writeIfNotDefault(ts, "stroke width", strokeWidth, double(1.0));


SVGRenderTreeAsText.cpp:317


writeIfNotDefault(ts, "dash offset", dashOffset, double(0.0));


PathQt.cpp:214


if (qFuzzyCompare(qAbs(cos_phi), double(1.0))) {


PathQt.cpp:299


if (!(qFuzzyCompare(span + (ea - sa) + 1, double(1.0)) &&


PathQt.cpp:300


qFuzzyCompare(qAbs(span), double(360.0)))) {


FEComponentTransfer.cpp:112


val = std::max(double(0.0), std::min(double(255.0), val));


FEComponentTransfer.cpp:127


val = std::max(double(0.0), std::min(double(255.0), val));


FEComponentTransfer.cpp:136


val = std::max(double(0.0), std::min(double(255.0), val));


FEComponentTransfer.cpp:146


val = std::max(double(0.0), std::min(double(255.0), val));


qdesigner_actions.cpp:1424


const double xOffset = page.left() + qMax(double(0.0), (page.size().width() - scaling * pixmapSize.width()) / 2.0);


qdesigner_actions.cpp:1425


const double yOffset = page.top() + qMax(double(0.0), (page.size().height() - scaling * pixmapSize.height()) / 2.0);


I also found a weird issue with webkit where some function was passing a float to a function template with no function to handle floats, so I added this line:

XPathValue.h:62


Value(float value) : m_type(NumberValue), m_bool(false), m_number(value) {}

I'm not fully sure that's the proper fix, but it's pretty good duct tape I say!


Step 3:


Look out! Here comes Tom!


Alright, now we get to compile this big guy.


Make sure you have a terminal in your QTSOURCE dir now.


This is the command to get this rolling:



Code:
./configure -arch arm  -xplatform linux-pandora-g++  -nomake examples -nomake demos -make tools -platform linux-g++ -prefix /mnt/utmp/kdelibs -force-pkg-config


Make sure to substitute my prefix value for yours..aka, your output directory. Also, I didn't tell it to make examples and demos, because, lets face it, I doubt that's what you wanted Qt compiled for. (It's already gona take eons to compile the rest, especially webkit.)


It will now ask you some questions, which I assume for your case you will answer "o" for open-source and "yes" for you agree.


It should then do it's business creating makefiles and compiling qmake for your host machine. If you get errors about ")" at end of line or what-not, you got the wrong architechture.


It should finally finish and say you can run "make" now. Do so and then take a nice long hike, or bubblebath, or play some games, etc. Otherwise you will be tortured by endless lines of g++ and wishes that you had a supercomputer.


Step 4:


Do stuff


Now you get to do what you wanted to do with these new Qt libs before this adventure. Maybe you wanted to try out Qt Quick..maybe you like compiling stuff, idk.


If the output dir happens also be the dir belonging to an app you are trying to compile, a "make install" may put things in it's place to continue forward with compiling.


Well, idk about you, but I got some shiny new Qt libs, and I hope you did too by following along.

My face when finished:


1WjJL.png


EDIT:added -force-pkg-config once I realized this was preventing it from being able to compile qtdbus too.


EDIT2:seems QtUiTools(needed for KDE) is not built without -make tools.


EDIT3:more double changes when making tools
 
Last edited by a moderator:
Back
Top