Log the pits that are encountered by the QT Linux static compilation

Source: Internet
Author: User
Tags sqlite

QT under the static compile Qt, according to my experience, if according to the kind of windows under the Official SDK installed directly after the file to compile is not feasible, need to download QT source package directly, At present, the source of Nokia is called QT-EVERYWHERE-OPENSOURCE-SRC tar package, to the online search, obediently, most people compiled this package actually took 12-13 hours! However, based on my experience of statically compiling QT under Windows, many of these things can be done without compiling, and in the end it took me about 40 minutes to compile everything. If you are directly using the Official SDK installation, then you have a dynamic library, and now you are compiled through the source package, so long as you compile a static library, because you already have a dynamic library, you even need to compile static release library is enough, who will be in peacetime compile time to use the kind of waste time static compile? When the product to be deployed to other machines, QT need to use the time to connect on it, so that other content, such as the dynamic library of Demo,examples are still available, install two version will not spend too much time, not the two worlds? Long story short, now say the installation step. 1. To download the Qt-everywhere source package online, if you just want the library, then you can also go to the following URL to find the version you need. http://www.qtcn.org/bbs/read.php?tid=10752. Unzip to your target directory 3. Select the part to compile with configure.     You can modify the configure file by directly qt_default_build_parts= "Libs tools examples Demos Docs translations", put examples, Docs,demos all removed (I only removed these three, theoretically if the dynamic version is installed, tools and translations (this is linguist) can also be removed. You can also specify options by adding –no-make * * * In the final configure directive (here is the parts name mentioned earlier) without modifying the Configure file   some options are default. These default options are not a problem in most cases, but if your program is to be deployed to some of the uncertain Linux systems, such as some systems that don't even have jpg,png libraries (these are the system libraries used in the Configure default option, it's tragic if the system doesn't have those libraries), Then you can join –qt-gif  -qt-libpng–qt-libmng–qt-.Libjpeg several options.   If you decide to use only static libraries for the final product release, then you don't need to compile the debug library, just compile release.   4. Generate Makefile Using ConfigureBecause you not only want to use your own compiled static library, you also want to be able to use the SDK automatically installed dynamic libraries and those demos,examples, in order to allow the two QT libraries to coexist, configure must be a static library with a different location of the dynamic Library folder, such as my SDK installed to/ opt/qtsdk-2010.05/, then I set up under/opt a folder called Qtstatic to hold the static library, and then use the Configure command:./configure–prefix/opt/qtstatic–static –release. Of course, I do not like to see the full screen of the mess of the output, and because a small error suddenly terminated the compilation, so the following options are specified:-continue When an error occurs, continue compiling the-silent as much as possible to show warnings and errors, etc. will not output the compilation instructions to the screen of course, if you did not modify the Configure file in the first way to prune the compilation module, do not forget to add the-nomake option, such as you do not want to compile examples, you can add:-nomake examples, This step can take a few minutes, and so on, because the project is relatively large. If you specify that the content of the compilation is not many, it should be done quickly.
Qt 4.7.4 Sample:
./configure-static-release-qt-zlib-qt-gif-qt-libpng-qt-libmng-qt-libjpeg-nomake Demos-nomake Examples-nomake doc S-qt-sql-sqlite-webkit-script-silent in the 64-bit arch, which seems to add -phonon-javascript-jit-scripttoolsThe project compiles the error, does not know why. after using QT 4.8The static compilation configuration on the WARNING prompts you to: Using static linking would disable the WebKit module.。 There is no WebKit static package after compilation. The following judgment exists in the Configure file: if ["$CFG _shared" = "no"];   Then echo "Warning:using static linking would disable the WebKit module." canbuildwebkit= "No" fi joins the-shared configuration item to compile the WebKit module, but It's still dynamic after compilation.。 It appears that you cannot statically compile a project with WebKit in Qt 4.8.0. Additionally the-qt-gif configuration item no longer exists and needs to be removed or replaced with-qt-libtiff if you need to generate a TIFF format picture. Qt 4.8 Sample:
./configure-release-qt-zlib-qt-libtiff-qt-libpng-qt-libmng-qt-libjpeg-nomake Demos-nomake Examples-nomake docs-q T-sql-sqlite-webkit-script-silent-shared

5. Compiling and installingIn the end, it's made and make install, but don't forget the multi-threaded build feature! If your machine is not going to do anything else this time, you can simply add the following options:-K When an error occurs, try to compile-j N at the same time, and recommend that the value of n is your CPU core number X1.5. Of course, I picked a slightly harsh value, my computer is the Pentium Dual-core t4300,make instruction is: make–k–j 4, then I saw the System Monitor CPU directly to 100%. The build is complete, and make install is ready. Of course, as a Linux system, you need to pay attention to folder permissions issues ... Well, if you don't understand the problem, I think you need to do a little bit more on Linux. problems occurred after joining-script-webkit:
/usr/bin/ld: cannot find -ljscore
$ cd/c/qt/4.7.4/src/3rdparty/webkit/javascriptcore/release $ cp libjscore.a/c/qt/4.7.4/lib/ $ cp libjscore.prl/c/qt/4.7.4/lib/ Copy the Libjscore.a and LIBJSCORE.PRL from the source directory to the Lib directory and perform make. after make install, the static compilation of the concrete project file will also report this problem. It is also possible to copy the two files into the Lib directory where Qt is statically compiled. 6. How to statically compile a programIn the pro file, add config +=static or config +=staticlib, depending on your project type. This allows the compiler to try to find a static library to connect to (including those outside the Qt Library), which, of course, does not preclude QT from statically connecting to some libraries that cause compatibility issues. This is a solution that has been proposed in QT centre and can be consulted if necessary: http://www.qtcentre.org/wiki/index.php?title=Building_static_applications 7. Dynamic/Static Two-version coexistence issuesTypically, you do not need to add the location of the QT library to the system variables. QT Creator can automatically scan to the version of the QT library that exists in the system, and if not, you can add the path to the static library through the creator Tool->options->qt4. While Qdevelop is not so smart, you can manually specify the location of include and Lib. Perhaps this is not a problem at all. If you miss a dynamic library, or if you don't want to experience the speed at which a snail crawls at a static compilation before the product is released, you can specify Config + = Shared in the pro file, and remember to select the appropriate version in project. 8. The problem of too large static version  First, statically compiled QT program A debug version of the program about 150M, a release version of 10M or so, so you know why I will not compile the static debug library it? Because there is no need. You can use tools like STRIP,UPX (Windows) to compress the huge programs you generate. Space and speed has always been a pair of enemies, Windows statically compiled programs, after UPX compression can be reduced to the original general volume, but the start speed is also serious decline. Of course, on the program start speed, their own design and implementation is the key, the final release of the program to do not compress, it needs to be based on the actual situation.    wish you a pleasant stay with QT! PS. Configure stage "Basic XLIB functionality test Failed" solution: Compile qt-x11-opensource-src-4.5.3 appears "basic XLib Functionality Test Failed "  WORKAROUND: This complete error message is in the./configure stage basic XLIB functionality Test failed! You might need to modify the Include and library search paths by editingqmake_incdir_x11 and qmake_libdir_x11 In/home/zhu /qt/qt-x11-opensource-src-4.5.2/mkspecs/linux-g++ into Config.test/x11/xlib execute make command, see error message g++-wl,-o1-o Xlib XLIB.O    -l/usr/x11r6/lib-lxext-lx11-lm/usr/bin/ld:cannot Find-lxext can see, g++ under/usr/x11r6/lib, Libxext.so is not found because of the need to install LIBX11 development package, according to their own system features, installation Libx11-dev Libxext-dev libxtst-dev  for Ubuntu, direct sudo apt-get Install Libx11-dev Libxext-dev Libxtst-dev for others:  yum install Libx11-devel Libxext-deveL libxtst-devel  Problem Solving!  =================== Gorgeous split line ==================  in order to compile under the Linux 64-bit system, I am shameless with the brother PW to a archlinux 64.PW brother to install, I began a painful journey. So it's really hairy.  pacman-syu more system pacman-s curlpacman-s opensshpacman-s gcc installation g++ need him to compile the source pacman-s libx11 Libxext libxt St Libxrender Install dependency package   start compiling.   Installation directory/qmake your project files. Promake If there is an error, remember to make a clean cleanup of the last compilation process file before next make. Otherwise, you may receive a COLLECT2:LD returned 1 exit status error prompt.  =================== Gorgeous split line ================== run after compiling the problem: If you use Qapplication or qwebpage dependent on X server, you say you don't give the whole X Window won't be able to run.   In the Lemon big reminder, check the implementation of &NBSP;PHANTOMJS, found that it is also using the above two, but can be run under the character interface. Check its project Wiki http://code.google.com/p/phantomjs/wiki/xvfbsetup find out XVFB can not rely on X (it is memory virtual x server). Yum install xorg-x11-server-xvfbxorg-x11-server-xorgxorg-x11-fonts* is used in these three dependent package ArchLinux  pacman-sy Xorg-server-xvfb to solve  * in addition, it is said that QT 4.8 or QT5 will use  lighthouse to solve X-dependency, you can see the following article: Http://blog.csdn.net/dbzhang800/ article/details/6526535 temporarily not stable version, do not intend to re-engage, first try Xvfb got.    Then Create the configuration file as follows (see this article for the relationship between/ETC/INIT.D and/etc/rc.d  http://left-uestc.appspot.com/2011/01/16/ init.d-rc.d-runlevel.html) After this, create an XVFB init file in/etc/init.d/xvfb containing the following:------------- -------------------------------------------------#! /bin/sh ### BEGIN INIT info# provides:xvfb# required-start: $local _fs $remote _fs# required-stop:# x-start-before:# Default-start:2 3 4 aa default-stop:### END INIT info # n=/etc/rc.d/xvfbn=/etc/init.d/xvfb set-e case "$ 1 "in  start) xvfb:0-screen 0 1024x768x24 &;;   stop|reload|restart|force-reload);   *)  echo "Usage: $N {start|stop|restart|force-reload}" >&2exit 1;; Esac exit 0-------------------------------------------------------------- after starting XVFB, specify The DISPLAY to app: display=:0   your directory/execute file  <arguments> ====== ============= Gorgeous Split Line ==================  This run may prompt &NBSP;IGLX ErroR:dlopen of/usr/lib/xorg/modules/dri/swrast_dri.so failed (/usr/lib/xorg/modules/dri/swrast_dri.so:undefined and what/ USR/SHARE/FONTS/TYPE1/USR/SHARE/FONTS/OTF What font directory can not be found. The workaround is to use the PACMAN-SS keyword | The more command queries the remote library of the ArchLinux. Let's see what kind of font you can fit. For example, put on  font-misc-meltho and xorg-fonts-type1 to complement the whole font. swrast_dri.so   God horse Run Pacman  -s mesa to install a graphics library just fine.  =================== Gorgeous split line ==================  about 10 minutes to automatically put the monitor to black, compared to the egg pain. and press any key, the screen takes a long time to light, this speed I can not bear.   Execute the following command to resolve the issue.  setterm-blank 0    This command will expire after a test reboot, so this command needs to be added to the startup script, which starts automatically after each boot.  archlinux added in the/ETC/BASH.BASHRC file:  setterm-blank 0   centos 5.4 was added/ETC/BASHRC in:  Setterm-blank 0

=================== Gorgeous split line ================== QT after static compilation Chinese may appear garbled. This is because the Libqcncodecs library that handles the text encoding is stored in the plugin form in the QT static compilation directory/plugs/codecs/libqcncodecs.a file. Text garbled, need to add into the font plug-in in the main.cpp file: #include <qtplugin>q_import_plugin (qcncodecs) and then add the library in the Project Pro file: Qtplugin + = Qjpeg Qcncodecs or libs + = QT Static compilation directory/PLUGS/CODECS/PLUGINS/CODECS/LIBQCNCODECS.A Note that when compiling dynamically, comment out or the compilation will not pass.  =================== Gorgeous split line ==================qt after static compilation, the Chinese font displayed by Webkit may be poor. This is because the font used by the General page style sheet does not automatically find an alternate font in a statically compiled QT (it is not a problem to dynamically compile, which is strange). The workaround is to replace the font-family setting in the page. I used the replacement method: When the page triggers the loadfinished signal, call the slot function, execute the Evaluatejavascript method using JS to build a style tag <style> *{font-family: Your replacement font! Improtant;} </style> Appentchild it to the head tag and replaces the page font setting with the high priority of the!improtant.

http://qbaok.blog.163.com/blog/static/1012926520119219573294/

Log the pits encountered by the QT Linux static compilation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.