QT lisence 解讀

 

對於桌面和移動平臺應用

  • 官方說明如下

複製代碼

Qt for Application Development lets you create applications for desktop and mobile platforms. 
It contains all the Qt APIs and the Qt Creator IDE for seamless cross-platform development.

Qt for Application Development is dual-licensed under commercial and open source licenses. 
The commercial Qt license gives you the full rights to create and distribute software on your 
own terms without any open source license obligations. With the commercial license you also 
have access to the official Qt Support and close strategic relationship with The Qt Company 
to make sure your development goals are met.

Qt for Application Development is also available under GPL and LGPLv3 open source licenses. 
Qt tools and some libraries are only available under GPL. See the comparison chart for details. 
The Qt open source licensing is ideal for use cases such as open source projects with open 
source distribution, student/academic purposes, hobby projects, internal research projects 
without external distribution, or other projects where all (L)GPL obligations can be met.

For more information, please see the FAQ.

複製代碼

  • Lincense 種類和費用

  • 各種 License 的權利和服務 (這裏關心的是 LGPL 下,可以動態鏈接 Qt 庫保持軟件私有)

  • 不幸的是,有一些 Qt 庫是以 GPL 的方式發佈(鑑於 GPL 的傳染性,就不能在私有軟件中以任何方式使用這些庫了,shit!)

  • 不幸的是,有一些 Qt 工具也是以 GPL 的方式發佈的(但幸運的是,不更改的情況下,可以 LGPL 的方式使用,見對圖中星號的解釋)

 

對於嵌入式平臺應用

複製代碼

With Qt for Device Creation, you can create embedded devices with modern UIs with maximum performance. 
In addition to Qt APIs, it comes with a full embedded tooling suite built around the Qt Creator IDE, 
and additional embedded solutions that help you reduce your time-to-market dramatically.

Qt for Device Creation is a product available only under a commercial license. This allows you to, 
for example, control your device’s user experience, and build proprietary functionality on top of Qt 
and to lock down your device. A commercial license from The Qt Company keeps your code proprietary 
where only you can control and monetize on your end product’s development, user experience and distribution.

複製代碼

 

對動態鏈接 LGPL 授權的庫,保持軟件私有的解釋

我們關心的是,包含 LGPL 的庫在自己公司的商業閉源程序中是否可行。

LGPL協議是一個商業友好的協議。你可以使用 LGPL協議的庫開發商業閉源程序。但是,它是有一些限制的。

- 如果你使用 LGPL 的庫開發閉源程序,使用動態鏈接的形式,那麼,你可以以任何形式發佈你的應用程序,商業的、非商業的、開源的、非開源的,隨你。

- 如果你因某種原因必須靜態鏈接一個基於 LGPL 協議發佈的庫,那麼你有義務進行下面的工作:

1. 你必須在你的文檔中說明,你的程序中使用了 LGPL 庫,並且說明這個庫是基於 LGPL 發佈的。
2. 你必須在你的應用程序發佈中包含一份 LGPL協議,通常就是那個 Lincense 文本文件。
3. 你必須開放使用了 LGPL 庫代碼的所有代碼,例如某些封裝器。但是,其他使用這些封裝器的代碼就不需要開放了。
4. 你必須包含你的應用程序的餘下部分的目標文件(通常就是我們所說的 .o 等等),或者是其他等價的文件,這部分源代碼並不是必須的。

解讀:

第1條,好理解。

第2條,好理解。

第3條,簡單來說,LGPL 協議要求,如果你的類使用了 LGPL 庫的代碼,那麼必須把這個類開源。例如,如果你的程序 app.exe 每個源文件都使用了 LGPL 庫的代碼,那麼你的所有源代碼都要開源。爲了避免這種情況,我們通常編寫一個封裝器,把 LGPL 庫的代碼封裝起來,這樣就只需要開放這個封裝器的代碼,而其他使用了這個封裝器的代碼就不需要開放。

第4條,是對第3條的一種補充,那些使用了封裝器的程序不需要開源,但是你必須把你編譯的那些中間文件開放出來,Windows 下就是那些 .o 文件。

 

舉例說明

假設我們使用一個名爲 Lib 的庫,這個庫是基於 LGPL 協議發佈的。

如果你使用 Lib.dll 做動態鏈接(Windows 下),好,一切 OK,你可以保持最終程序完全的私有。

如果你要使用靜態鏈接,那麼你需要如何組織你的代碼。如果你有一個 main.cpp(我們假設所有使用 Lib 庫的函數都是用了 lib_ 前綴):

main.cpp

複製代碼

int main()
{
    lib_init();
    lib_do_something();
    lib_done();
    lib_close();
 
    return 0;
}

複製代碼

現在你已經完成了 main.cpp,但是你必須把它開源!因爲它使用了 LGPL 庫的代碼。這是上面第三條規定的。

如果我不想把 main.cpp 開源,怎麼辦呢? 好,我新建一個文件 lib_wrapper.cpp:

 lib_wrapper.cpp

複製代碼

void my_lib_init()
{
    lib_init();
}

void my_lib_do_something()
{
    lib_do_something();
}

void my_lib_done()
{
    lib_done();
}

void my_lib_close()
{
    lib_close();
}

複製代碼

在 main.cpp 中,我做相應的修改:

複製代碼

int main()
{
    my_lib_init();
    my_lib_do_something();
    my_lib_done();
    my_lib_close();

    return0;
}

複製代碼

現在,main.cpp 不再是直接使用了 LGPL 庫的代碼了,因此它不需要開源,而我們的封裝器 lib_wrapper.cpp 必須開源。

好,編譯一下我們的程序,你會得到 main.o(Windows 下)這個目標文件。

在最終程序的發佈中,我需要包含以下文件:

1.一份文檔,其中聲明:這個程序使用了 Lib 庫,這個庫是基於 LGPL 協議發佈的。

2. LGPL.txt

3. lib_wrapper.cpp

4. main.o

這樣,用戶可以通過修改 lib_wrapper.cpp 的內容改變你使用 LGPL 庫的方式,例如:

複製代碼

void my_lib_done ()
{
    lib_done();
    lib_close();
}

void my_lib_close()
{
    //lib_close();
}

複製代碼

然後編譯這個 lib_wrapper.cpp,最終重新鏈接。一個新的可執行程序誕生啦!

 

相信到這裏大家已經對 Qt 提供的這三種協議有了基本的瞭解,通常還會有一個疑問,就是基於這三種授權協議的Qt產品到底有多少功能上的區別,是不是商業版本的會更完整,性能更好一些?這裏可以負責任的說:99%的代碼都是一樣的,無論是GPL, LGPL 還是 Commercial,功能,性能都沒有區別,唯一的區別就在於授權協議的不同。

還有一點需要說明的就是,由於 LGPL 是在 Qt4.5 這個版本里面才引入的,所以之前的 Qt 版本,4.4 或者 3.x 的版本,並不提供 LGPL 協議,是不可逆的。同時未來發布的Qt版本,就一直會提供三種不同的授權協議版本。

 

總結: 鑑於 Qt 授權協議的限制,如果項目沒有特別要求,建議使用 wxWidgets 開發商業產品

    如果以找工作爲出發點,還是跟着 Qt 走吧

////////////////////////////////////////////////////////////////////////////////

本文部分內容來自於網友博客,如有侵權請聯繫我。

完。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章