QtWebkit開發環境配置及編譯方法-Windows32bit

來源:互聯網
上載者:User

標籤:des   style   code   java   http   tar   

Dependencies
  • First of all you need a version of Qt for Windows. If you are an Open Source developer then you can download the Open Source Edition of Qt for Windows from the Nokia Website: http://qt.nokia.com/downloads; 針對Windows32位的版本為Qt 5.0.1 for Windows 32-bit (VS 2010, 481 MB)
  • Note that you need to enable ICU support in the Qt build (also see http://doc-snapshot.qt-project.org/5.0/requirements-win.html)
    • Make sure that Qt is configured with -openssl if you want HTTPS support in QtWebKit. You will need the non-light version ofWin32 OpenSSL libraries.
  • Install ActiveState Perl
  • Install Python 2.x (and add the installation location to your PATH)
  • The following external GNU tools are needed from the GnuWin32 Project:
    • Bison
    • GPerf
    • Grep
    • Flex
    • LibIconv (needed for bison)
    • Make (not necessary if you want to build using MSVC)
  • Install Ruby

Please install these tools in a path without spaces (i.e. not in "C:\Program Files")

Make sure the GnuWin32 packages are in your PATH as well as Perl and Python. You also need to have %QTDIR% set and have %QTDIR%\bin in your PATH.
If you have Cygwin‘s bin directory in your path, make sure that it comes after ActiveState Perl and GnuWin32. You might have to remove it completely from your PATH if you have problems with slashes and backslashes while building using MinGW. mingw32-make and GnuWin32‘smake will use sh.exe to run commands if they find it in the PATH.

Building QtWebKit
  • Open a Qt Command Prompt from the Start Menu.
    • Alternatively you can use a MSVC or MinGW command line environment that matches the version of Qt you downloaded and make sure qmake is accessible in PATH.
      Note that building inside Cygwin or MSYS is currently not supported. Please use a Windows command prompt.
  • Chdir into the WebKit source tree
  • Run perl Tools\Scripts\build-webkit --qt --release
  • Wait :)
  • Try to run WebKitBuild\Release\bin\QtTestBrowser.exe
Notes about building QtWebKit with the Qt/Windows OpenSource Edition
  • If you want to compile using multiple cores:
    • On MinGW you can try set MAKE_COMMAND=mingw32-make -j%NUMBER_OF_PROCESSORS%.
      If this do not work you might have to Ctrl-C build-webkit‘s execution, go in the WebKitBuild\Release\ directory and run:
      mingw32-make -C JavaScriptCore -f Makefile.Release -j%NUMBER_OF_PROCESSORS% && mingw32-make -C WebCore -f Makefile.Release -j%NUMBER_OF_PROCESSORS% && mingw32-make
    • On MSVC use the CL environment variable along with the /MP switch:
      set CL= /MP
  • If you haven‘t set up your PATH already to include the GnuWin32 packages then you may want to execute the following command:set PATH=C:\GnuWin32\bin;C:\Perl\bin;%PATH% Provided that the GnuWin32 packages are installed in C:\GnuWin32\bin and Perl inC:\Perl\bin.
  • If you get build errors in JavaScriptCore\bindings\NP_jsobject.cpp or similar then please make sure that the Microsoft Platform SDK is NOT in your %INCLUDE% path because it conflicts with your MingW headers.
  • If you get build errors after makefile generation ("Makefile:178: * Multiple target patterns. Stop.") then you‘re probably still using the Cygwin version of make. Try removing Cygwin from your %PATH% for the time being (it‘s not currently supported, as mentioned above).
A ‘Works For Me‘ Step-by-Step Guide to building QtWebKit on Windows using mingw-w64/w32
  1. The patch in bug report https://bugs.webkit.org/show_bug.cgi?id=38747 may not yet have been applied to Qt git, apply manually if necessary
  2. Until Qt 4.7 is released, use the git version of Qt 4.7: http://qt.gitorious.org/qt/qt/trees/4.7
  3. Get a mingw-w64 build with mingw32-make:
    • I‘m assuming you‘re running Windows x64, as you will be testing the build :)
    • Two options:
      • drangon: http://mingw-w64-dgn.googlecode.com/files Download the mingw-w64-bin-x86_64-<date> package Download the make-w64-bin-x86_64-<date> package Extract them both to C:\mingw64 so that mingw32-make.exe and g++.exe are present in the C:\mingw64\bin folder
      • sezero: http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20BuildsDownload any of the mingw-w64-x86_64-mingw_<date> packages. The exp/new/old suffixes are not important here Extract the package to C:\mingw64 so that g++.exe is present in C:\mingw64\bin Rename included gmake.exe to mingw32-make.exe
  4. Set up your environment:
    • Qt sources are in C:\Qt so that configure.exe is present in that directory
    • perl is installed: http://strawberryperl.com/ (installer should add perl.exe to PATH)
    • open cmd.exe
    • run following commands:
      set PATH=C:\mingw64\bin;C:\Qt\bin;%PATH%set QTDIR=C:\Qtcd C:\Qtconfigure -qt-style-windowsxp -qt-style-windowsvista -phononmingw32-make
  5. Everything should have built. Have fun!

Remarks: mingw-w64/w32 also provides a toolchain targetting 32-bit windows. Sezero provides builds:http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/ The procedure to compile Qt is exactly the same, only that he mingw64 folder name should be mingw32.

A ‘Works For Me‘ Step-by-Step Guide to Building QtWebKit on Windows using MinGW
  1. The the mentioned GnuWin32 tools
  2. Download QT SDK (and QT Creator) and Download ActivePerl
  3. Open for example a Qt Command Prompt from the Start Menu. Click Start->Program Files->Qt->QT Command Prompt. In fact, you really do need to use Qt Command Prompt for this rather than the normal windows command prompt.
  4. Make sure the GnuWin32 packages are in your PATH as well as Perl (set PATH=C:\program files\gnuwin32\bin;C:\Perl\site\bin;%PATH%.
  5. You also need to have %QTDIR% set and have %QTDIR%\bin in your PATH.
  6. Trim your PATH down as much as possible. Remove Git and Mingw from your PATH if you have them installed, their presence can cause odd build failures. For example, the PATH that works for me is:
     set Path=c:\GnuWin32\bin;c:\Qt\2009.01\qt\bin;c:\Qt\2009.01\bin;C:\Perl\bin;C:\Windows\system32;c:\Qt\2009.01\mingw\bin;C:\Perl\site\bin;C:\Windows
    • Note that c:\Qt\2009.01\qt above will vary depending on the QT SDK that you downloaded. You should modify it appropriately.
  7. Download WebKit from svn (make sure you‘ve left the location of your svn client in your %PATH% above):
    $ svn checkout http://svn.webkit.org/repository/webkit/trunk %HOME%\WebKit$ cd %HOME%/WebKit
  8. Change into the WebKit source tree: cd c:\location\of\webkit
  9. For some reason, the build command was unable to create the WebKitBuild\Release folders by itself on my PC. I had to do mkdir WebKitBuild and mkdir WebKitBuild\Release before building.
  10. You may need to do a mkdir c:\tmp. The WebKit build relies on the existence of c:\tmp when building in Windows.
  11. Build the patched webkit (release mode): $perl Tools\Scripts\build-webkit --qt --release
  12. The webkit build takes forever, you can shorten it using the build-webkit‘s --no-svg or --minimal flags:
        $perl Tools\Scripts\build-webkit --qt --release --no-svg    $perl Tools\Scripts\build-webkit --qt --release --minimal
Speedup Git on Windows

Git tends to be rather slow for repositories with a huge amount of files on Windows. One way to deal with that is to use a sparse-checkout, to "ignore" certain files. The LayoutTests directory is certainly a good candidate, if you currently do not need these files. A sparse-checkout uses a config file (.git/info/sparse-checkout) to determine if a file should be checked out or not. Files mentioned in the config file will be part of the checkout. Files not mentioned in the config file will be ignored. There is also a syntax to invert this logic, but it is currently not working well with directories.

  1. Create a .git/info/sparse-checkout file that will ignore the LayoutTests directory:
    /*!LayoutTests
  2. Enable sparse-checkout:
    git config core.sparsecheckout true
  3. Remove the LayoutTests directory if it is already there:
    rmdir /s LayoutTests
  4. Update the git tree cache:
    git read-tree -m -u HEAD
  5. Check which files have been excluded:
    git ls-files -v | grep ^S
     
    參考編譯方法:
     
    1.Qt官網下載最新版本:http://qt-project.org/downloads
    2.將下載的壓縮包解壓(例如,路徑為:F:/QtWebKit),配置相關環境變數:
    -----建立兩個變數名,分別為QTDIR(值為 F:/QtWebKit/qt-windows-open.....),QMAKESPEC(值為 win32-msvc20XX; 這裡的XX,根據VS的版本決定,本人用的是2010,所以為win32-msvc2010)
    3.編譯原始碼
    -----開啟VS軟體,進入Visual Studio Tools中,運行命令列,鎖定到qt的源碼目錄下,運行命令:configure.exe -webkit
    -----編譯過程中會出現GPL授權相關提示,yes即可,第一步會產生qmake
    -----然後運行nmake命令,編譯完即成功編譯
    4.編譯應用程式,同上,一次執行qmake和nmake命令,會在debug目錄下產生可執行檔
    5.qt安裝環境裡包含webkit原始碼,而且內建一個簡單的Browser項目
    6.將Browser工程設為啟動項目,然後編譯即可。
     

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.