Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to compile qt with Linux

2025-02-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the relevant knowledge of how Linux compiles qt, the content is detailed and easy to understand, the operation is simple and fast, and has a certain reference value, I believe you will have something to gain after reading this Linux how to compile qt article, let's take a look.

First download the source package qt-everywhere-opensource-src-5.6.0.7z and then decompress it

7z x-o/home/o/qt-src/qt-opensource-src-5.6.0 qt-everywhere-opensource-src-5.6.0.7z cd / home/o/qt-src/qt-opensource-src-5.6.0 I unzip it into / home/o/qt-src/qt-opensource-src-5.6.0 here and enter this directory after decompression.

Configure generates makefile by using. / configure-- help to see what parameters are available. Instead of posting commands to output the results, you can translate all the options directly.

Installation options-prefix specifies the deployment directory (default / usr/local/Qt-5.6.0)-extprefix installation directory (default SYSROOT/PREFIX)-hostprefix [dir] the installation directory of the build tools running on this host, if not given, use the current directory. (default EXTPREFIX) you can use these to change the layout of the installation. Please note that all directories except sysconfdir should be located under-prefix/ hostprefix

Option role-the bindir user executable will be installed in this directory (default PREFIX/bin)-headerdir header file installation directory (default PREFIX/include)-libdir library file installation directory (default PREFIX/lib)-archdatadirQT related data will be installed to (default PREFIX)-plugindir plug-in installation directory (default ARCHDATADIR/plugins)-libexecdir program executable installation directory (default ARCHDATADIR/libexec) ARCHDATADIR/bin for MinGW)-importdir import QML1 installation directory (default ARCHDATADIR/imports)-qmldir import QML2 installation directory (default ARCHDATADIR/qml)-datadirQT stand-alone data installation directory (default PREFIX)-docdir document installation directory (default DATADIR/doc)-number of translations of translationdirQt programs according to installation directory (default DATADIR/translations)-sysconfdir settings search directory using QT programs (default PREFIX/etc/xdg)-examplesdir sample file installation directory (default) PREFIX/examples)-testsdir test file installation directory (default PREFIX/tests)-hostbindir host executable installation directory (default HOSTPREFIX/bin)-hostlibdir host library file installation directory (default HOSTPREFIX/lib)-hostdatadirqmake uses the * in the first column of the data installation directory (default HOSTPREFIX) Configure option to indicate default and feasible. + indicates default, but it needs to be evaluated (tested) before it can be accepted.

Option role *-release compiles and links release versions of Qt

-debug compiles and links debug versions

-debug-and-release compiles and links release and debug versions (MAC only)

-force-debug-info creates symbolic links for release builds

-developer-buildQt developer compilation and linking options (including automated test / output) *-no-optimized-tools does not build optimized host tools even in debug versions

-optimized-tools builds optimized host tools, even in debug versions

-opensource compiles and links Qt open source versions

Commercial version of Qt compiled and linked by commercial

-confirm-license automatically confirms licenses (using open source or commercial)

-the C++ standard used by QT for compiling c++std (clocked 98, clocked 11, clocked 14, clocked 1z) defaults: the maximum supported version is *-shared to create and use Qt shared libraries.

-static creates and uses QT static libraries

-no-largefile disables large file support +-largefile enables QT to access files greater than 4 GB

-no-accessibility uncompiled accessibility support disabling access is not recommended, it will destroy QStyle and may affect QT build this option enables to create a source incompatible version of QT, which does not support +-accessibility compilation access support.

-no-sql- completely disables SQL.

-qt-sql- enables SQL in the Qt SQL module, which is not enabled by default.

-plugin-sql- enables SQL to be linked at run time as a plug-in. Possible values are: [db2 ibase mysql oci odbc psql sqlite sqlite2 tds]

-system-sqlite uses the operating system SQLite

-no-qml-debug is not built on QML debugging support +-qml-debug build QML debugging support

-Target operating system and compiler built by platform target (default detection host system) read the readme file to get a list of supported operating systems and compilers

-do not use the SSE2 directive for no-sse2 compilation

-do not use the SSE3 directive for no-sse3 compilation

-do not use the SSSE3 directive for no-ssse3 compilation

-do not use the SSE4.1 directive for no-sse4.1 compilation

-do not use the SSE4.2 directive for no-sse4.2 compilation

-do not use the AVX directive for no-avx compilation

-do not use the AVX2 directive for no-avx2 compilation

-do not use the MIPS DSP directive for no-mips_dsp compilation

-do not use the MIPS DSP Rev2 directive for no-mips_dspr2 compilation

-qtnamespace puts all the Qt library code into namespace {.}

-qtlibinfix rename index libQt*.so to libQt*.so

-testcocoonInstrument Qt with the TestCocoon code coverage tool.

-gcovInstrument Qt with the GCov code coverage tool.

-D shows adding a macro definition to the preprocessor

-I show add an include path

-L shows adding a library path +-pkg-config uses pkg-config to detect including library paths. By default, the configuration determines whether to use pkg-config or not to have heuristics such as checking environment variables.

-no-pkg-config disables pkg-config support

-force-pkg-config enforces the use of pkg-config (skips pkg-config usability heuristics).

-help,-h displays help information. Third-party libraries:

Option function

-qt-zlib uses the zlib library that comes with QT +-system-zlib uses the zlib library that comes with the operating system. Http://www.gzip.org/zlib

-no-mtdev do not compile mtdev support mtdev includes application support for multi-touch protocol +-mtdev enable mtdev support. +-no-journald do not output logs to journald. Journald is a new Syslog method for Linux servers.

-journald log output to journald+-no-syslog do not export log to syslog.

-syslog outputs the log to syslog.

-no-gif do not compile GIF read support

-no-libpng do not compile PNG support

-qt-libpng uses the libpng+-system-libpng that comes with Qt and the libpng http://www.libpng.org/pub/png that comes with the operating system

-no-libjpeg do not compile JPEG support.

-qt-libjpeg uses the libjpeg.+-system-libjpeg that comes with QT and the libjpeg http://www.ijg.org that comes with the system

-no-freetype do not compile Freetype2 support.

-qt-freetype uses the libfreetype.+-system-freetype that comes with QT and uses the libfreetype that comes with the system (if it exists) (enabled, if the-fontconfig option is enabled). Http://www.freetype.org

-no-harfbuzz do not compile HarfBuzz-NG support. *-qt-harfbuzz uses the HarfBuzz-NG that comes with QT for text formation. You can still disable it by setting the QT_HARFBUZZ environment variable to "old".

-system-harfbuzz uses the system's own HarfBuzz-NG area for text formation. You can still disable http://www.harfbuzz.org by setting the QT_HARFBUZZ environment variable to "old"

-no-openssl do not compile OpenSSL support

-openssl enables runtime OpenSSL support.

-openssl-linked enables and links OpenSSL support

-no-libproxy do not compile libproxy support +-libproxy uses the libproxy that comes with the operating system.

-qt-pcre uses the PCRE library.+-system-pcre that comes with QT and the PCRE library that comes with the operating system

-qt-xcb uses xcb-libraries that comes with QT. (libxcb.so will still use the. +-system-xcb that comes with the operating system to attract the xcb- libraries that comes with it.

-xkb-config-root sets the default XKB config root. This option is only used with-qt-xkbcommon-x11.

-qt-xkbcommon-x11 uses xkbcommon library that comes with QT in building xcb. +-system-xkbcommon-x11 uses xkbcommon library that comes with the operating system in building xcb.

-no-xkbcommon-evdev when compiling libinput support, do not use X-less xkbcommon.*-xkbcommon-evdev when compiling libinput support, use X-less xkbcommon.

-no-xinput2 do not compile XInput2 support. *-xinput2 compilation XInput2 support.

-no-xcb-xlib do not compile Xcb-Xlib support. *-xcb-xlib compilation Xcb-Xlib support.

-no-glib do not compile Glib support. +-glib compilation Glib support.

-no-pulseaudio do not compile PulseAudio support. +-pulseaudio compilation PulseAudio support.

-no-alsa do not compile ALSA support. +-alsa compilation ALSA support.

-no-gtkstyle do not compile GTK theme support. +-gtkstyle compilation GTK theme support. Additional options:

Option function

-make adds the components to be built when make. (default: libs tools examples

-nomake excludes components at build time

-skip excludes the establishment of the whole module

-no-compile-examples only installs the source code of examples, do not compile it.

-no-gui do not build Qt GUI modules and dependencies. +-gui build Qt GUI modules and dependencies.

-no-widgets do not build Qt Widgets modules and dependencies. +-widgets build Qt Widgets modules and dependencies

-R shows the path to adding a runtime library to build Qt libraries.

-l shows adding a library.

-no-rpath does not use the library installation path as a runtime library path on Apple's platform, which means using absolute installation names (based on libdir) dynamic libraries and frameworks. +-rpath links Qt libraries and executables use the library installation path as the runtime library path. Equivalent to-R install_libpath

-continue if there is an error, try to continue.

-verbose,-v prints details of the configuration process for each step.

-silent reduces the generated output so that warnings and errors can be seen more easily.

-no-nis do not compile NIS support. *-nis compilation NIS support.

-no-cups do not compile CUPS support. *-cups compilation CUPS support. Cups/cups.h and libcups.so.2.

-no-iconv does not compile support for iconv (3). *-iconv compilation support for iconv (3).

-no-evdev does not compile support for evdev. *-evdev compilation support for evdev.

-no-tslib does not compile support for tslib tslib is support for touch screen *-tslib compilation support for tslib.

-no-icu does not compile support for ICU libraries. This is IBM released character set code conversion library +-icu compiler support for ICU libraries.

-FontConfig support in no-fontconfig non-compiler system + FontConfig support in fontconfig compilation system

-no-strip does not remove unwanted symbols from the use of binaries and libraries by strip. *-strip removes unwanted symbols from the use of binaries and libraries by strip during installation *-no-pch does not use precompiled header support.

-pch uses precompiled header support. *-no-ltcg does not use link time code generation

-ltcg is generated using the link time code.

-no-dbus do not compile the Qt D-Bus module. +-dbus-linked compile the Qt D-Bus module and link to libdbus-1.

-dbus-runtime compiles the Qt D-Bus module and dynamically loads libdbus-1.

-reduce-relocations reduces reloading through additional linker optimizer libraries (qt/X11 and Qt/linux embedded only; experimental; requires GNU ld > = 2.18)

-no-use-gold-linker do not use GNU gold linker for links. +-use-gold-linker use GNU gold linker for links.

-force-asserts forces Q_ASSERT to be enabled, even in release builds.

-sanitize [address/thread/memory/undefined] enables the sanitizer of the specified compiler.

-device cross-platform compilation equipment (experimental)

-device-option add device option for device mkspec (experimental) *-no-separate-debug-info does not store debugging information in a separate file

-separate-debug-info will debug information to a separate file

-no-xcb do not compile Xcb (X protocol C-language Binding) support. *-xcb compilation Xcb support.

-no-eglfs do not compile EGLFS (EGL Full Screen/Single Surface) support. *-eglfs compilation EGLFS support.

-no-kms do not compile the backend of KMS. *-kms compiles the backend of KMS.

-no-gbm do not compile the backend of GBM. *-gbm compiles the backend of GBM.

-no-directfb do not compile DirectFB support. *-directfb compilation DirectFB support.

-no-linuxfb do not compile Linux Framebuffer support. *-linuxfb compilation Linux Framebuffer support. *-no-mirclient do not compile Mir client support.

-mirclient compilation Mir client support.

-qpa sets the default QPA platform (example xcb, cocoa, windows).

-xplatform target specifies the target platform (when compiling across platforms)

-sysroot will be set to the sysroot of the target compiler and qmake and also set the pkg-confing path.

-no-gcc-sysroot when using-sysroot, it disables passing-sysroot to the compiler

-no-feature- is not compiled in.

-in feature- compilation. The available features are described in src/corelib/global/qfeatures.txt

-qconfig local uses src/corelib/global/qconfig-local.h instead of the default (all).

-qreal [double/float] specifies the type for qreal. The default value is double. Note that changing this flag affects binary compatibility.

-no-opengl disables OpenGL support.

-opengl enables OpenGL support. Without parameters, this will attempt to automatically detect OpenGL ES 2.0 and later, or regular desktop version of OpenGL. Using es2 will replace automatic detection

-no-libinput disables libinput support. *-libinput enables libinput support.

-no-gstreamer disables GStreamer support. +-gstreamer enables GStreamer support. With no parameters, this will attempt to automatically detect GStreamer 0.10 and 1.0. GStreamer 1.0 is the available time used by default. Use 0.10 or 1.0 to override automatic detection. *-no-system-proxies does not use the system network proxy by default

-system-proxies by default, use the system network proxy

-treat warnings as normal when no-warnings-are-errorsMake

-warnings-are-errorsMake treats warnings as an error (if-developer-build is enabled) QNX/Blackberry option: option role-no-slog2 does not compile slog2 support-slog2 compilation slog2 support-no-pps does not compile pps support-pps compilation pps support-no-imf does not compile imf support-imf compilation imf support-no-lgmon does not compile lgmon support-lgmon compilation lgmon support Android option:

Option function

-android-sdk pathAndroid SDK root directory (default $ANDROID_SDK_ROOT)

-android-ndk pathAndroid NDK root directory. (default $ANDROID_NDK_ROOT)

-android-ndk-platform sets the android platform version (default android-9)

-android-ndk-host sets the android NDK host type (linux-x86, linux-x86_64, etc.) (default $ANDROID_NDK_HOST)

-android-arch sets android architecture (armeabi, armeabi-v7a, x86, mips, arm64-v8a, x86 / 64, mips64) (default armeabi-v7a)

-android-toolchain-version sets the android tool chain version (default 4.9)

-no-android-style-assets does not compile code that automatically extracts style-assets from the runtime device. Setting this will make Android-style behavior inappropriate, but compatible with lgpl2.1 license *-android-style-assets compilation automatically extracts style-assets code through run-time devices. This option will make the lgpl2.1 license for the Android platform incompatible. Generate makefile below are the options I use when compiling. -platform this option is used to specify the target platform. You can see the directory under the qt source directory / qtbase/mkspecs/, which is the platform supported by QT. You can go to this directory to modify the qmake.conf file to specify compiler and compilation options.

/ home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0 [o@o-pc] [12:09] >. / configure-prefix / home/o/pragram/qt_5.6.0_gcc5.2.1-release-debug-opensource- c++std canals 11-static-qt-sql-mysql-qt-sql-sqlite-platform linux-g++-64-qt-zlib-no-journald-qt-libpng-qt- Libjpeg-openssl-opengl below is to ask whether to view the open source protocol or accept it directly. Just pass by yes.

Type'3'to view the GNU Lesser General Public License version 3. Type'L'to view the Lesser GNU General Public License version 2.1. Type 'yes' to accept this license offer. Type 'no' to decline this license offer. Do you accept the terms of either license? Yes...... If you encounter a link check failure, here is an example, that is, the xcb library check failed.

Running configuration tests (phase 1)... Done running configuration tests. Creating qmake... .Done. Running configuration tests (phase 2)... The test for linking against libxcb and support libraries failed! You might need to install dependency packages, or pass-qt-xcb. See src/plugins/platforms/xcb/README. This is easy to solve, just press libxcb-***-dev. The same is true of other library check failures. You can also use the xcb library that comes with Qt with the-qt-xcb option.

After generating makefile and compiling configure, there will be the following prompt, which will let you use make to compile and make install to install. "

1 Build type: linux-g++-64 (x86: 64, CPU features: mmx sse sse2) 2 3 Build options: 4 Configuration. Accessibility accessibility-atspi-bridge alsa audio-backend avx avx2 caterpillar 11 clock-gettime clock-monotonic compile_examples concurrent dbus dbus-linked debug egl eglfs egl_x11 enable_new_dtags evdev eventfd fontconfig full-config getaddrinfo getifaddrs gif glib gstreamer-0.10 harfbuzz iconv icu inotify ipv6ifname jpeg kms large-config largefile libudev linuxfb medium-config minimal-config mremap nis opengl openssl png posix_fallocate precompile_header pulseaudio qpa qpa reduce_exports reduce_relocations rpath small-config sse2 sse3 sse4_1 sse4_2 ssse3 static system-freetype threadsafe-cloexec use_gold_linker xcb xcb- Glx xcb-plugin xcb-render xcb-sm xcb-xlib xinput2 xkbcommon-evdev xkbcommon-qt xlib xrender zlib 5 Build parts. Libs tools examples 6 Mode. Debug 7 Using sanitizer (s). None 8 Using C++ standard. 11 9 Using gold linker. Yes 10 Using new DTAGS. Yes 11 Using PCH. Yes 12 Using LTCG. No 13 Target compiler supports: 14 SSE2/SSE3/SSSE3. Yes/yes/yes 15 SSE4.1/SSE4.2. Yes/yes 16 AVX/AVX2. Yes/yes 17 18 Qt modules and options: 19 Qt D-Bus. Yes (linked to dbus-1) 20 Qt Concurrent. Yes 21 Qt GUI. Yes 22 Qt Widgets. Yes 23 Large File. Yes 24 QML debugging. Yes 25 Use system proxies. No 26 27 Support enabled for: 28 Accessibility. Yes 29 ALSA. Yes 30 CUPS. No 31 Evdev. Yes 32 FontConfig. Yes 33 FreeType. Yes (system library) 34 Glib. Yes 35 GStreamer. Yes 0.10) 36 GTK theme. No 37 HarfBuzz. Yes (bundled copy) 38 Iconv. Yes 39 ICU. Yes 40 Image formats: 41 GIF. Yes (in QtGui, using bundled copy) 42 JPEG. Yes (in QtGui, using bundled copy) 43 PNG. Yes (in QtGui, using bundled copy) 44 libinput. No 45 Logging backends: 46 journald. No 47 syslog. No 48 mtdev. No 49 Networking: 50 getaddrinfo. Yes 51 getifaddrs. Yes 52 IPv6 ifname. Yes 53 libproxy. No 54 OpenSSL. Yes (loading libraries at run-time) 55 NIS. Yes 56 OpenGL / OpenVG: 57 EGL. Yes 58 OpenGL. Desktop 59 OpenVG. No 60 PCRE. System 61 pkg-config. Yes 62 PulseAudio. Yes 63 QPA backends: 64 DirectFB. No 65 EGLFS. Yes 66 EGLFS i.MX6. No 67 EGLFS i.MX6 Wayland. No 68 EGLFS EGLDevice.... No 69 EGLFS GBM. No 70 EGLFS Mali. No 71 EGLFS Raspberry Pi. No 72 EGLFS X11. Yes 73 LinuxFB. Yes 74 Mir client. No 75 XCB. Yes (system library) 76 EGL on X. Yes 77 GLX. Yes 78 MIT-SHM. Yes 79 Xcb-Xlib. Yes 80 Xcursor. Yes (loaded at runtime) 81 Xfixes. Yes (loaded at runtime) 82 Xi. No 83 Xi2. Yes 84 Xinerama. Yes (loaded at runtime) 85 Xrandr. Yes (loaded at runtime) 86 Xrender. Yes 87 XKB. Yes 88 XShape. Yes 89 XSync. Yes 90 XVideo. Yes 91 Session management. Yes 92 SQL drivers: 93 DB2. No 94 InterBase. No 95 MySQL. Qt 96 OCI. No 97 ODBC. Yes (plugin) 98 PostgreSQL. Yes (plugin) 99 SQLite 2. No 100 SQLite. Qt-qt 101 TDS. No 102 tslib. No 103 udev. Yes 104 xkbcommon-x11. Yes (bundled copy, XKB config root: / usr/share/X11/xkb) 105 xkbcommon-evdev. Yes 106 zlib. Yes (bundled copy) 107 108 109 WARNING: Using static linking will disable the use of dynamically 110 loaded plugins. Make sure to import all needed static plugins, 111 or compile needed modules into the library. 112 Info: creating super cache file / home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/.qmake.super 113 114 Qt is now configured for building. Just run 'make'. 115 Once everything is built, you must run 'make install'. 116Qt will be installed into / home/o/pragram/qt_5.6.0_gcc5.2.1 117118Prior to reconfiguration, make sure you remove any leftovers from 119the previous build.configure successful prompt

This is the end of the article on "how Linux compiles qt". Thank you for reading! I believe you all have a certain understanding of the knowledge of "how Linux compiles qt". If you want to learn more, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report