Build Qt 5.6 with examples installed



  • To build Qt from source and have the examples installed do I just need to eliminate -nomake examples from my configuration? I am a little confused as to whether that option actually builds the example programs or just makes it so they are installed to the kit with make install.

    The reason I am asking instead of just trying it is because when I tried eliminating that option my build failed. I didn't want to spend a lot of time troubleshooting if I didn't need to, but it seems to me that if it wasn't actually trying to build the examples that there wouldn't be much that could go wrong. But when I built and installed with the -nomake examples option, the examples didn't get installed.

    Thanks for any help anyone can provide!
    Paul


  • Qt Champions 2016

    @Paul-H.

    To build Qt from source and have the examples installed do I just need to eliminate -nomake examples from my configuration?

    Yes.

    I am a little confused as to whether that option actually builds the example programs or just makes it so they are installed to the kit with make install.

    Both. qmake generates a makefile that does both the building and the installing.

    The reason I am asking instead of just trying it is because when I tried eliminating that option my build failed.

    Possible, depending on the source you got (version and OS). Sometimes the examples break (usually after a change in Qt or a module) and don't want to build.

    Are you building Qt for development? If so my advice is to make a development build and forgo the make install altogether. You can configure the kit later by simply pointing creator to the correct qmake binary (or if you build on the command line, invoke the correct qmake explicitly).



  • @kshegunov
    Thanks for the help. So just to be clear, when I don't exclude the examples, the Makefile will be configured to actually build executables for every example for the modules that are configured to build? When I have installed on my Windows box using the online installer, I only get the source code of the examples installed, all in their own directory tree which is found by Qt Creator, which is what I would like to duplicate from source.

    I am building a LFS/BLFS (Linux From Scratch) system. I installed it, using the BLFS book instructions, for building other packages from source that link to it. I also built and installed Qt Creator for development (mostly just playing around and learning), which is when I realized I didn't have the examples. I can browse to my build directory and open them up individually from there, but I was hoping to have them integrated in to the Welcome page of Creator.

    Thanks again!
    Paul


  • Qt Champions 2016

    @Paul-H.

    Hello Paul,

    So just to be clear, when I don't exclude the examples, the Makefile will be configured to actually build executables for every example for the modules that are configured to build?

    Exactly!

    When I have installed on my Windows box using the online installer, I only get the source code of the examples installed, all in their own directory tree which is found by Qt Creator, which is what I would like to duplicate from source.

    On linux this doesn't make much sense (its process is not as with windows). When you do make install a set of binaries (i.e. the Qt libraries) are copied to the appropriate system locations (usually /lib or /usr/lib), so when you start an application they can be found and loaded. Now, with installing, if I recall correctly the headers are not even copied to /usr/include, because they aren't needed for anything but development. You can still access the sources, headers, the example projects and so on in the original source tree.

    So, my original advice is standing - use a developer's build (it's similar to what you get with windows). When configuring with ./configure -developer-build like described here everything is built and accessible under a single directory - sources, headers, libraries, tools, examples etc.

    I am building a LFS/BLFS (Linux From Scratch) system.

    I suppose that's possible, but I find no real benefit in building everything myself. I'd rather choose a good distribution (that has more users than maintainers) and use that. I personally use Debian (testing flavor), but any good distro is enough for development (e.g. Arch and Debian derivatives - *buntu, Mint). This I think would probably be more beneficial for learning than waiting a few hours for a kernel to be built.

    I can browse to my build directory and open them up individually from there, but I was hoping to have them integrated in to the Welcome page of Creator.

    The welcome page of Qt Creator is somewhat problematic on Linux. In my distro's package (I'm using the pre-built IDE) they are explicitly disabled.

    Kind regards,
    Konstantin.


  • Lifetime Qt Champion

    Hi,

    Just some additional notes. Qt's make install call will install all of Qt in one known location like /usr/local/qt5 unless you toyed with the various prefix related variables. Why not globally in the system ? Because it would overwrite what your distribution is providing and while it should likely not be a problem, your distribution might be patching Qt for e.g. security purposes or bug fixes not yet upstreamed etc.

    Also doing a -developer-build implies that you are building Qt with the intention to work on it for either bug fixes and/or feature implementation. If you want a "no install" build follow the recommendation provided here.


  • Qt Champions 2016

    @SGaist

    Why not globally in the system ? Because it would overwrite what your distribution is providing and while it should likely not be a problem, your distribution might be patching Qt for e.g. security purposes or bug fixes not yet upstreamed etc.

    Forget that maintainers sometimes do small patches. Doing make install introduces terrible pollution to the system locations and makes maintaining your system hell!

    Also doing a -developer-build implies that you are building Qt with the intention to work on it for either bug fixes and/or feature implementation.

    It does? I don't do these things, but I like the developers build very much. :)



  • Thanks for all the input!.

    I personally use Debian (testing flavor), but any good distro is enough for development

    I like Debian, also. I use it for my server at work.
    I'm building this LFS system just because I wanted to see if I could, and to learn more about the inner workings of the operating system. I'm actually building it on a flash drive. If nothing else, it has helped me become more comfortable with installing and configuring software from source on Linux. This is just something for me to play around with.

    Doing make install introduces terrible pollution to the system locations and makes maintaining your system hell!

    I am installing Qt under /opt by making a directory with the full version name (qt-5.6.0 in this case) then a symbolic link /opt/qt5 pointing to that directory. More details on the configuration are in that link I posted, if you're interested. So it's not polluting my /usr directory tree at all using make install. Please don't take this as arguing against your approach. I appreciate the tip and knowing about other options. This is just the way I am choosing to do it this time around.

    I did succeed in building with the examples, They all installed, but only 2 examples showed up on the Qt Creator Welcome page, the Context2d and Default Prototypes. After investigating I found that the examples-manifest.xml file in the doc/qtscript/ directory for those 2 examples didn't have qtbase/ prefixing all the paths, but the rest that I checked do. I removed the qtbase/ prefix from all the paths in the xml file in the doc/qtgui/ directory and those examples then appeared on the Welcome page. I ended up doing, as root, find $QT5DIR/doc/ -name examples-manifest.xml -exec sed -i -e "s@qtbase/@@g" {} \; to change the rest of the files. I can't say for sure if all the examples are showing up, but there are a bunch there now. Is there something I could have done in the configure stage when building to make them correct in the first place?

    Thanks again for the help!
    Paul


  • Qt Champions 2016

    @Paul-H.

    I'm building this LFS system just because I wanted to see if I could, and to learn more about the inner workings of the operating system.

    Fair enough.

    I am installing Qt under /opt by making a directory with the full version name (qt-5.6.0 in this case) then a symbolic link /opt/qt5 pointing to that directory. ... So it's not polluting my /usr directory tree at all using make install.

    Then you're using a prefix for your configure script, which is really good. I learned the hard way to do that. ;)

    Is there something I could have done in the configure stage when building to make them correct in the first place?

    I don't know anything special that needs to be done for the examples. Perhaps @SGaist will rescue me yet again ... :)

    Kind regards.


  • Lifetime Qt Champion

    You don't need any symbolic link, just use Qt from /opt directly.

    As for the examples-manifest-xml files, you may have found something new.

    I don't build the examples when building Qt because it's essentially wasted time and disk space. They are easy to find and build otherwise. (e.g. the Regular Expression tool).

    AFAIK, the configure call looks good. Did you call configure only once or did you re-run it without cleaning the sources ?



  • You don't need any symbolic link, just use Qt from /opt directly.

    I realize I don't need the link, just thought it would make it easier for managing future builds.

    I don't build the examples when building Qt because it's essentially wasted time and disk space.

    Maybe some day I'll feel the same way :) Not quite there yet! Seriously though, my main thing is I want to know how to do it if desired. It was bugging me that it didn't work like I expected.

    Did you call configure only once or did you re-run it without cleaning the sources ?

    Not very likely. I built out of source in a directory along side the source. I delete the build directory and recreate it if I change anything in the configuration. I don't recall deviating from that procedure.

    I appreciate all the help. I'll mark this solved since my question was answered and I was able to accomplish what I wanted. Maybe I'll fire up a fresh build before I go to bed tonight and see if the results with the examples-manifest.xml files repeats.

    Paul


  • Lifetime Qt Champion

    Good ! Out of source builds are way nicer :)

    That would be interesting yes, there might be a bug lurking there.



  • I re-built last night and got the same results with the examples-manifest.xml files. For reference, here is how I built:

    export QT5PREFIX=/opt/qt5
    
    ../qt-everywhere-opensource-src-5.6.0/configure	\
    	-prefix $QT5PREFIX 	\
    	-sysconfdir /etc/xdg   	\
    	-confirm-license        \
    	-opensource             \
    	-dbus-linked            \
    	-openssl-linked         \
    	-system-harfbuzz        \
    	-system-sqlite          \
    	-no-rpath               \
    	-optimized-qmake        \
    	-skip qtwebengine
    
    make
    make docs
    

    I also noticed that my fix for removing the qtbase/ from the path in the xml files only fixed the examples that are built in the qtbase build directory. Fixing the rest of the files manually won't be quite as easy because some have the same name twice like this qt<module>/qt<module>/ and some have it like this qt<module>/<module>. Only the first qt<module>/ needs to be removed. Plus, qt<module>/ is in the URLs, which need to remain. Here are example entries from the build directories to show what I am talking about. Note the docUrl=, imageURL=, projectPath= and <fileToOpen> tags.

    qtbase/doc/qtgui/examples-manifest.xml

            <example name="Analog Clock Window Example" docUrl="qthelp://org.qt-project.qtgui.560/qtgui/qtgui-analogclock-example.html" projectPath="qtbase/gui/analogclock/analogclock.pro" imageUrl="qthelp://org.qt-project.qtgui.560/qtgui/images/analogclock-window-example.png">
                <description><![CDATA[The Analog Clock Window example shows how to draw the contents of a custom window.]]></description>
                <tags>android,ios,gui,clock,analog,window</tags>
                <fileToOpen mainFile="true">qtbase/gui/analogclock/main.cpp</fileToOpen>
            </example>
     
    

    qt3d/doc/qt3d/examples-manifest.xml

            <example name="Qt 3D: Audio Visualizer Example" docUrl="qthelp://org.qt-project.qt3d.560/qt3d/qt3d-audio-visualizer-qml-example.html" projectPath="qt3d/qt3d/audio-visualizer-qml/audio-visualizer-qml.pro" imageUrl="qthelp://org.qt-project.qt3d.560/qt3d/images/audio-visualizer-qml-example.png">
                <description><![CDATA[Demonstrates combining Qt 3D rendering and Qt Quick 2 elements.]]></description>
                <tags>qt3d,audio,visualizer</tags>
                <fileToOpen>qt3d/qt3d/audio-visualizer-qml/main.cpp</fileToOpen>
                <fileToOpen mainFile="true">qt3d/qt3d/audio-visualizer-qml/main.qml</fileToOpen>
            </example>
    
    

    qtmultimedia/doc/qtmultimedia/examples-manifest.xml

            <example name="Audio Devices Example" docUrl="qthelp://org.qt-project.qtmultimedia.560/qtmultimedia/qtmultimedia-multimedia-audiodevices-example.html" projectPath="qtmultimedia/multimedia/audiodevices/audiodevices.pro" imageUrl="qthelp://org.qt-project.qtmultimedia.560/qtmultimedia/images/audiodevices.png">
                <description><![CDATA[Testing the available audio devices and their configuration.]]></description>
                <tags>devices,multimedia,audio</tags>
                <fileToOpen>qtmultimedia/multimedia/audiodevices/main.cpp</fileToOpen>
                <fileToOpen>qtmultimedia/multimedia/audiodevices/audiodevices.h</fileToOpen>
                <fileToOpen mainFile="true">qtmultimedia/multimedia/audiodevices/audiodevices.cpp</fileToOpen>
            </example>
    
    

    The 2 example projects that I mentioned in an earlier post are the only ones that work without modification. So I don't know if this is a bug in Qt Creator, the Qt build, or neither one and there is something else gone wrong on my end. As another note, the xml files on my Windows box, which were installed with the online installer, don't have the extra prefix in the paths, which leads me to believe it is not a problem with Qt Creator.

    Paul


  • Lifetime Qt Champion

    Just to be sure, is that after running make install ?



  • I didn't install this time. I just compared them with the files in the original build directory and installation directory. I still have the new build directory so I can do a make install to see if that changes anything.

    Paul


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.