久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何在 Windows 或 Linux,32 或 64 位,在 Visual Stud

How to compile Qt 5 under Windows or Linux, 32 or 64 bit, static or dynamic on Visual Studio or g++(如何在 Windows 或 Linux,32 或 64 位,在 Visual Studio 或 g++ 上靜態或動態編譯 Qt 5) - IT屋-程序員軟件開發技術分享
本文介紹了如何在 Windows 或 Linux,32 或 64 位,在 Visual Studio 或 g++ 上靜態或動態編譯 Qt 5的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

只是為了幫助那些試圖這樣做的人的帖子,因為我沒有博客.

這也適用于 linux.隨意編輯和改進它.

解決方案

注意:我還寫了另一篇文章給

9.

  • 對于VS2012:針對VS2012執行以下命令

     設置 QMAKESPEC=win32-msvc2012設置 QTDIR=C:QtQt5.7qtbase設置 PATH=C:QtQt5.7qtbasein;%PATH%

注意:對于 Qt 5.8+ 版本,設置 QMAKESPEC 環境變量被認為是錯誤的.不要為新版本這樣做.

用于動態鏈接(需要 8 GB)

configure -debug-and-release -opensource -platform win32-msvc2012 -opengl desktop

用于沒有示例的動態鏈接(需要 2 GB)

configure -debug-and-release -opensource -platform win32-msvc2012 -opengl desktop -nomake examples -nomake tests現在最后一個命令取決于您要編譯的內容.只需鍵入 configure -help 并查看可用的命令行參數是什么.

對于靜態鏈接(需要 70 GB,是的,這很瘋狂,不制作示例和演示更合理).

configure -debug-and-release -opensource -platform win32-msvc2012 -opengl desktop -static

對于沒有示例的靜態鏈接(需要 4 GB,更有意義).

configure -debug-and-release -opensource -platform win32-msvc2012 -opengl desktop -static -nomake examples -nomake tests

現在這將需要一兩分鐘,然后按如下方式使用 jom(假設它是在 C:Qtjom 中提取的):

C:Qtjomjom.exe -j 50

50 表示您要使用的內核數.我使用 50 是因為我有 8 個線程,并且只使用 8 個不會完全占用所有內核,所以更多更好,但不要太貪婪,因為它可能會使您的系統沒有響應.

  • 對于VS2010:對于VS2010執行以下命令

    set QMAKESPEC=win32-msvc2010設置 QTDIR=C:QtQt5.7qtbase設置 PATH=C:QtQt5.7qtbasein;%PATH%

注意:對于 Qt 5.8+ 版本,設置 QMAKESPEC 環境變量被認為是錯誤的.不要為新版本這樣做.用于動態鏈接(需要 8 GB)

configure -debug-and-release -opensource -platform win32-msvc2010 -opengl desktop

用于沒有示例的動態鏈接(需要 2 GB)

configure -debug-and-release -opensource -platform win32-msvc2010 -opengl desktop -nomake examples -nomake tests

最后一條命令取決于您要編譯的內容.只需鍵入 configure -help 并查看可用的命令行參數是什么.對于靜態鏈接(需要 70 GB,是的,這很瘋狂,不制作示例和演示更合理).

configure -debug-and-release -opensource -platform win32-msvc2010 -opengl desktop -static

對于沒有示例的靜態鏈接(需要 4 GB,更有意義).

configure -debug-and-release -opensource -platform win32-msvc2010 -opengl desktop -static -nomake examples -nomake tests

現在這將需要一兩分鐘,然后按如下方式使用 jom(假設它是在 C:Qtjom 中提取的):

C:Qtjomjom.exe -j 50

50 表示您要使用的內核數.我使用 50 是因為我有 8 個線程,并且只使用 8 個不會完全占用所有內核,所以更多更好,但不要太貪婪,因為它可能會使您的系統沒有響應.

  • 對于 linux:

Linux 與 Windows 有一個小區別.建議在linux下編譯后安裝.老實說,這是對我來說沒有問題的唯一方法.

Linux 執行以下命令.不要忘記用 Qt 源的正確路徑替換路徑

 export QMAKSPEC=linux-g++導出 QTDIR=/home/username/Qt5.7/qtbase導出路徑=/home/username/Qt5.7/qtbase/bin:$PATH

注意:對于 Qt 5.8+ 版本,設置 QMAKESPEC 環境變量被認為是錯誤的.不要為新版本這樣做.

假設您要將編譯后的源代碼安裝到目錄/home/username/Qt5.7-install.在這種情況下,將以下內容添加到以下 any 配置命令中:

-prefix/home/username/Qt5.7-install

警告:請勿安裝到同一源目錄.這完全是錯誤的!

如果沒有設置-prefix,會選擇默認路徑,我猜是/usr/local/.我不喜歡使用 root 安裝任何東西.我總是更喜歡在我的用戶文件夾中安裝,這樣可逆性和升級都不是問題.

以下是不同的 configure 命令,具體取決于您要執行的操作.

用于動態鏈接(需要 8 GB)

./configure -debug-and-release -opensource -platform linux-g++ -opengl desktop

用于沒有示例的動態鏈接(需要 2 GB)

./configure -debug-and-release -opensource -platform linux-g++ -opengl desktop -nomake examples -nomake tests

現在最后一個命令取決于您要編譯的內容.只需輸入 ./configure -help 并查看可用的命令行參數.

對于靜態鏈接(需要 70 GB,是的,這很瘋狂,不做示例和測試更合理).

./configure -debug-and-release -opensource -platform linux-g++ -opengl desktop -static

對于沒有示例的靜態鏈接(需要 4 GB,更有意義).

./configure -debug-and-release -opensource -platform linux-g++ -opengl desktop -static -nomake examples -nomake tests

制作完成后,運行make命令

make -j 50

50 表示您要使用的內核數.我使用 50 是因為我有 8 個線程,并且只使用 8 個不會完全占用所有內核,所以更多更好,但不要太貪婪,因為它可能會使您的系統沒有響應.

  1. 等待 2 個多小時直到編譯完成.

  2. 清理!在 Windows 上使用此命令可以節省大量空間:C:Qtjomjom.exe clean 而對于 linux 使用此命令:make clean

您可以將編譯文件夾的大小從 8 GB 減少到 2.5 GB(用于動態鏈接),從 70 GB 減少到 35 GB(用于靜態鏈接).

<小時>

為了在 Qt Creator 中使用這個編譯版本:

  1. 啟動 Qt Creator
  2. 轉到工具、選項
  3. 從左側的列表中選擇構建并運行".
  4. 轉到Qt 版本"標簽
  5. 單擊添加"并從 bin 所在的文件夾中選擇 qmakeqtbase 是,所以從上面:

    C:QtQt5.7qtbaseinqmake.exe

(或者Linux選擇你安裝編譯好的Qt源碼的路徑,相當于本教程中的/home/username/Qt5.7-install/qtbase/bin/qmake)

  1. 點擊應用"
  2. 轉到套件"標簽
  3. 點擊添加"
  4. 給它一個名字,選擇合適的編譯器(對于 VISUAL STUDIOEXPRESS DO NOT SELECT amd64 FOR 64-BIT ,它行不通,選擇x86_amd64 代替)
  5. 點擊確定.

現在只需打開一個項目,您就會發現它要求您選擇添加的工具包.

享受:)

Just a post to help those guys trying to do that, since I don't have a blog.

This works for linux too. Feel free to edit it and improve it.

解決方案

Note: There's also another article I wrote to compile from GIT source here with an automated script on Windows. You may modify it for Linux as the difference is shown in this post.

This article is continuously being updated. If this helps you, please give it a "thumbs up" so that I could know that it's helping people and not being useless.

If you have any comments or you found typos, please let me know so that I can fix them.

First thing, it doesn't matter whether you want to compile 32 or 64 bit version. The only difference is the command prompt shortcut that you have to choose from Visual Studio, which will initialize different environment variables.


Let's begin with this:

  1. Download and install Perl: Download link

  2. Download and install Python: Download link

  3. Download and install Windows SDK (probably not necessary, but recommended) I use Windows 8, so this is the version I used: Download link ,Otherwise find the proper version for your Windows.

  4. Download and install DirectX SDK (probably necessary if you wanna compile with OpenGL) Download link

  5. Download and extract jom to some folder (not needed for linux) (jom is a tool for compiling stuff with VS in parallel, there's a way to do this with nmake, but I'm not familiar with it) Download link

  6. Download Qt Opensource, and extract it, say to C:QtQt5.6, so now the folder qtbase can be found in C:QtQt5.6qtbase .

  7. Only for Windows: DO YOU REALLY WANT IT TOTALLY STATIC?

    Usually, even if you choose the compilation to be static, the compiler itself will still not merge its libraries statically. If you want your compiled source to be fully static with respect to the compiler (Visual Studio), you have to do this tweak in the QMAKE files of Qt.

    Go to the file (starting from your Qt source directory), for versions higher than 2012, just use the right version everywhere (such as win32-msvc2015):

    • a. For VS2012: qtbasemkspecswin32-msvc2012qmake.conf

    • b. For VS2010: qtbasemkspecswin32-msvc2010qmake.conf

    • c. For Qt 5.5.0 and later (with any VS version): qtbasemkspecscommonmsvc-desktop.conf

    and edit the following lines

     QMAKE_CFLAGS_RELEASE    = -O2 -MD
     QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -MD -Zi
     QMAKE_CFLAGS_DEBUG      = -Zi -MDd
    

    to

     QMAKE_CFLAGS_RELEASE    = -O2 -MT
     QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -MT -Zi
     QMAKE_CFLAGS_DEBUG      = -Zi -MTd
    

Note: Qt 5.6+ have a configure parameter -static-runtime that will do this for you. You may not need to do this manually anymore for new versions of Qt.

  1. Start the terminal in linux, or in Windows, start the terminals of Visual Studio (which have the correct environment variables set, or alternatively use vcvarsall.bat). To start the command prompt and let it do this automatically for you, go to Start, All Programs:

    For Windows versions prior to 8: Find the Microsoft Visual Studio 201x folder, and launch the command prompt (either x86 for 32 bit or x64 for 64 bit).

    For Windows 8: go to Start, type "cmd" and all versions available for command prompt will show up. Choose the Visual Studio version appropriate (x86 for 32 bit or x64 for 64 bit).

Following is a screenshot of how it may look like. Always tend to select "Native" if it exists.

9.

  • For VS2012: Execute the following commands for VS2012

     set QMAKESPEC=win32-msvc2012
     set QTDIR=C:QtQt5.7qtbase
     set PATH=C:QtQt5.7qtbasein;%PATH%
    

Note: Setting QMAKESPEC environment variable is considered wrong for Qt versions 5.8+. Don't do it for the new versions.

For dynamic linking (needs 8 GBs)

configure -debug-and-release -opensource -platform win32-msvc2012 -opengl desktop

For dynamic linking with no examples (needs 2 GB)

configure -debug-and-release -opensource -platform win32-msvc2012 -opengl desktop -nomake examples -nomake tests

 Now the last command depends on what you want to compile. Just type configure -help and see what the available command-line parameters are.

For static linking (needs 70 GBs, yes it's crazy, it's more reasonable not to make the examples and demos).

configure -debug-and-release -opensource -platform win32-msvc2012 -opengl desktop -static

For static linking with no examples (needs 4 GBs, makes more sense).

configure -debug-and-release -opensource -platform win32-msvc2012 -opengl desktop -static -nomake examples -nomake tests

Now this will take a minute or two, then use jom as follows (assuming it's extracted in C:Qtjom):

C:Qtjomjom.exe -j 50

50 represents the number of cores you want to use. I use 50 because I have 8 threads and using only 8 will not occupy all cores completely, so more is better, but don't get too greedy as it could make your system not responsive.

  • For VS2010: Execute the following commands for VS2010

    set QMAKESPEC=win32-msvc2010
    set QTDIR=C:QtQt5.7qtbase
    set PATH=C:QtQt5.7qtbasein;%PATH%
    

Note: Setting QMAKESPEC environment variable is considered wrong for Qt versions 5.8+. Don't do it for the new versions. For dynamic linking (needs 8 GBs)

configure -debug-and-release -opensource -platform win32-msvc2010 -opengl desktop

For dynamic linking with no examples (needs 2 GB)

configure -debug-and-release -opensource -platform win32-msvc2010 -opengl desktop -nomake examples -nomake tests

The last command depends on what you want to compile. Just type configure -help and see what the available command-line parameters are. For static linking (needs 70 GBs, yes it's crazy, it's more reasonable not to make the examples and demos).

configure -debug-and-release -opensource -platform win32-msvc2010 -opengl desktop -static

For static linking with no examples (needs 4 GBs, makes more sense).

configure -debug-and-release -opensource -platform win32-msvc2010 -opengl desktop -static -nomake examples -nomake tests

Now this will take a minute or two, then use jom as follows (assuming it's extracted in C:Qtjom):

C:Qtjomjom.exe -j 50

50 represents the number of cores you want to use. I use 50 because I have 8 threads and using only 8 will not occupy all cores completely, so more is better, but don't get too greedy as it could make your system not responsive.

  • For linux:

There's one small difference for Linux over Windows. It's recommended in linux to install after compiling. Honestly this is the only way it works for me without problems.

Execute the following commands for Linux. Don't forget to replace the paths with the correct paths of your Qt source

    export QMAKESPEC=linux-g++
    export QTDIR=/home/username/Qt5.7/qtbase
    export PATH=/home/username/Qt5.7/qtbase/bin:$PATH

Note: Setting QMAKESPEC environment variable is considered wrong for Qt versions 5.8+. Don't do it for the new versions.

Let's say you want to install the compiled source to the directory /home/username/Qt5.7-install. In this case, add the following to any of the configure commands below:

-prefix /home/username/Qt5.7-install

Warning: DO NOT install to the same source directory. That's plain wrong!

If -prefix is not set, the default path will be chosen, which is /usr/local/ I guess. I don't like to install anything using root. I always prefer installing in my user folder, so that reversibility and upgrades are not a problem.

The following are different possible configure commands depending on what you want to do.

For dynamic linking (needs 8 GBs)

./configure -debug-and-release -opensource -platform linux-g++ -opengl desktop

For dynamic linking with no examples (needs 2 GB)

./configure -debug-and-release -opensource -platform linux-g++ -opengl desktop -nomake examples -nomake tests

Now the last command depends on what you want to compile. Just type ./configure -help and see what the available command-line parameters are.

For static linking (needs 70 GBs, yes it's crazy, it's more reasonable not to make the examples and tests).

./configure -debug-and-release -opensource -platform linux-g++ -opengl desktop -static

For static linking with no examples (needs 4 GBs, makes more sense).

./configure -debug-and-release -opensource -platform linux-g++ -opengl desktop -static -nomake examples -nomake tests

After making is done, run make command

make -j 50

50 represents the number of cores you want to use. I use 50 because I have 8 threads and using only 8 will not occupy all cores completely, so more is better, but don't get too greedy as it could make your system not responsive.

  1. Wait 2+ hours till the compilation is complete.

  2. Clean up! You can save a lot of space using this command for Windows: C:Qtjomjom.exe clean And this command for linux: make clean

You can reduce the size of your compiled folder from 8 GB to 2.5 GB (for dynamic linking) and from 70 GB to 35 GB (for static linking).


In order to use this compiled version in Qt Creator:

  1. Start Qt Creator
  2. Go to Tools, Options
  3. Select Build and Run from the list on the left.
  4. Go to "Qt Versions" tab
  5. Click on "Add" and select qmake from the folder where your bin in qtbase is, so from above:

    C:QtQt5.7qtbaseinqmake.exe

(or for Linux choose the path where you installed the compiled Qt source, which is equivalent to /home/username/Qt5.7-install/qtbase/bin/qmake in this tutorial)

  1. Click "Apply"
  2. Go to "Kits" tab
  3. Click "Add"
  4. Give it a name, choose the appropriate compiler (FOR VISUAL STUDIO EXPRESS DO NOT SELECT amd64 FOR 64-BIT , IT WON'T WORK, CHOOSE x86_amd64 INSTEAD)
  5. Click OK.

Now just open a project and you'll find it asking you to choose the kit you added.

Enjoy :)

這篇關于如何在 Windows 或 Linux,32 或 64 位,在 Visual Studio 或 g++ 上靜態或動態編譯 Qt 5的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How can I read and manipulate CSV file data in C++?(如何在 C++ 中讀取和操作 CSV 文件數據?)
In C++ why can#39;t I write a for() loop like this: for( int i = 1, double i2 = 0; (在 C++ 中,為什么我不能像這樣編寫 for() 循環: for( int i = 1, double i2 = 0;)
How does OpenMP handle nested loops?(OpenMP 如何處理嵌套循環?)
Reusing thread in loop c++(在循環 C++ 中重用線程)
Precise thread sleep needed. Max 1ms error(需要精確的線程睡眠.最大 1ms 誤差)
Is there ever a need for a quot;do {...} while ( )quot; loop?(是否需要“do {...} while ()?環形?)
主站蜘蛛池模板: 99亚洲精品视频 | 午夜免费福利电影 | 在线观看国产精品一区二区 | 粉嫩av在线 | 欧美激情国产精品 | 久久精品国产一区二区三区 | 不卡一区二区三区四区 | 国产精品乱码一区二三区小蝌蚪 | 日本精品一区二区 | 日韩高清三区 | 亚洲va在线va天堂va狼色在线 | 午夜不卡一区二区 | 99久久久99久久国产片鸭王 | 久久99精品久久久久子伦 | 国产三级一区二区三区 | 中文字幕在线免费观看 | 99re视频精品 | 国产激情视频 | h视频在线观看免费 | 日韩精品一区二区三区中文字幕 | 青青草中文字幕 | 91中文视频 | 国产精品一区2区 | 国产精品伦理一区 | 国产精品久久久 | 午夜欧美 | 久优草| 亚洲一区二区不卡在线观看 | 天堂网中文字幕在线观看 | 一级欧美| 免费1区2区3区 | 亚洲狠狠| 午夜免费福利影院 | 国产91丝袜在线18 | 国产精品高潮呻吟久久 | 日韩在线视频免费观看 | 国产一区二区 | 成人免费久久 | 免费精品久久久久久中文字幕 | 天天躁日日躁狠狠躁白人 | 日韩欧美精品在线 |