I'm looking at all the options that can be run for the configure
script provided with Qt. (specifically qt-everywhere-opensource-src-5.2.0).
After considerable searching, I've determined this stuff is poorly documented at best so I was hoping I could get some help. When I look at the descriptions for prefix
and sysroot
configuration options:
~/qt-everywhere-opensource-src-5.2.0$ ./configure -help | grep "sysroot"
-extprefix<dir>
... When -sysroot is used, install everything to<dir>
,
-sysroot<dir>
...... Sets<dir>
as the target compiler's and qmake's sysroot and also sets pkg-config paths.
-no-gcc-sysroot ..... When using -sysroot, it disables the passing of --sysroot to the compiler
~/qt-everywhere-opensource-src-5.2.0$ ./configure -help | grep "prefix"
-prefix<dir>
...... This will install everything relative to<dir>
-extprefix<dir>
... When -sysroot is used, install everything to<dir>
,
-hostprefix [dir] .. Tools and libraries needed when developing
So I've used -prefix
before, and it did exactly as described. It placed everything at the provided <dir>
, then when I built my application using <prefix_dir>/bin/qmake
and installed that on my target platform it wanted to find all the shared object libraries at <prefix_dir>/lib
.
I'm under the impressions that if I use -sysroot
it will install everything at <sysroot_dir>
then when I install my application on the target platform it will search in /lib
. At least I hope that's true.
Now if my assumption is correct... then what's the point of -extprefix
? Are they saying that if I can redirect where things good if I use both -sysroot
and -extprefix
?
And what would be a reason why I would want to use -no-gcc-sysroot
? If I wanted my Qt libs to be installed at "sysroot" why wouldn't I want gcc
to use/know the same sysroot?
An explanation of some of these would be great, even better if I can get some practical examples of how to correctly use these options.
These are options that are used when building embedded platforms. Yes they are a royal mess. So here's only a partial answer:
To add to the confusion:
Which flags you want to use when compiling for a target not your host, depends on a boatload of hardcoded assumptions inside configure.
generally -sysroot plus -prefix should work for most use cases.
i.e. when you have:
$ ls ~/mytarget
lib bin share dev
you could just use -sysroot ~/mytarget -prefix /
One practical example would be cross compiling Qt for Raspberry Pi and then creating a "sister" kit to add to Qt Creator.
The following command install Qt on the Pi after mounting the Pi's root filesystem:
./configure -opengl es2 -device linux-rasp-pi-g++ -device-option CROSS_COMPILE=$RPI_TOOLCHAIN -sysroot $RPI_SYSROOT -opensource -confirm-license -optimized-qmake -reduce-exports -release -make libs -prefix /usr/local/qt-5.5.1-pi -skip qtwebkit
The following command then installs the binaries on the desktop by using Pi's root file system.
./configure -opengl es2 -device linux-rasp-pi-g++ -device-option CROSS_COMPILE=$RPI_TOOLCHAIN -sysroot $RPI_SYSROOT -opensource -confirm-license -optimized-qmake -reduce-exports -release -make libs -extprefix /usr/local/qt-5.5.1-pi -skip qtwebkit
Note that the only difference is the use of -extprefix instead of -prefix which directs the installation location.
Note: You can install Qt on host and target simultaneously by specifying both prefix and extprefix in the same line
Now you can add this kit to your Qt Creator by specifying your qmake path, device, compiler, debugger and sysroot. So you can create a qt project on your desktop and then build and run on either the desktop or the pi depending on the kit you choose.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With