Qt GPL, LGPL & Commercial License

Qt GPL, LGPL & Commercial License

2009年06月27日 星期六 13:55

From:

http://www.qteverywhere.com/

 

Qt 4.5中提供了三种授权协议,分别是GPL, LGPL和Commercial,可能很多人要问,为什么同样的一个产品要提供三种授权协议,什么情况下使用什么的样的授权协议最合适?在这里我就大致解释一下:

GPL全称是The GNU General Public License,是目前大多数的GNU程序和超过半数的自由软件使用的许可协议。GPL的出发点是代码的开源/免费使用和引用/修改/衍生代码的开源/免 费使用,但不允许修改后和衍生的代码做为闭源的商业软件发布和销售。
GPL协议的主要内容是只要在一个软件中使用(”使用”指类库引用,修改后的代码或者衍生代码)GPL 协议的产品,则该软件产品必须也采用GPL协议,既必须也是开源和免费。这就是所谓的”传染性”。GPL协议的产品作为一个单独的产品使用没有任何问题, 还可以享受免费的优势。

回到LGPL,LGPL的全称是 GNU Lesser General Public License,GNU 较宽松公共许可证,也是由协议是由自由软体基金会发布的许可证,是一个主要为类库使用设计的开源协议,和GPL要求任何使用/修改/衍生之GPL类库的的 软件必须采用GPL协议不同。LGPL允许商业软件通过类库引用(link)方式使用LGPL类库而不需要开源商业软件的代码。这使得采用LGPL协议的 开源代码可以被商业软件作为类库引用并发布和销售。

除了GPL和LGPL两种开源协议之外,Qt还提供了Commercial商业协议,Qt的商业协议是由Nokia定义的,由Nokia和购买方签 订的,具有法律效应的Qt产品授权协议。 Commercial License相教与GPL和LGPL,对于商业客户提供了更多的灵活性,客户可以任意的修改Qt的源代码,开发商业软件,而不需要公开任何源代码。并 且,在Commercial License中,我们还提供了技术支持服务。当然,商业授权协议是需要费用的。

到底什么时候需要选择GPL和LGPL呢?一个最显而易见的理由就是他们都是免费的,使用LGPL和GPL版本的Qt是不需要支付任何费用的,当然 我们也相应的不会提供技术支持。如果你打算开发真正的开源软件,并希望使用者也可以保持开源,那么GPL是更好的选择,因为所有人,不论你自己还是将来基 于你的代码进行再次开发都必须开源。如果你打算开发闭源(不开放源代码)的商业软件,那么LGPL则更适合,但必须满足下面两个条件:
1. 你的应用程序应该动态链接Qt函数库,并使你的应用程序与未做修改的LGPL库分开发布。同时必须确保使用者(接受者)知道应用程序使用了LGPL版本的Qt;
2. 如果你对LGPL版本的Qt进行了任何修改,并发布,则必须遵循LGPL 条款发布。任何使用者有权利得到这些修改(通常情况下是源代码),并且确保使用者可以通过这些修改自己生成相应你修改过的Qt版本。

相信到这里大家已经对Qt提供的这三种协议有了基本的了解,通常大家还会有一个疑问,就是基于这三种授权协议的Qt产品到底由多少功能上的区别,是 不是商业版本的会更完整,性能更好一些?这里我可以负责任的说:99%的代码都是一样的,无论是GPL, LGPL还是Commercial,功能,性能都没有区别,唯一的区别就在于授权协议的不同。

还有一点需要说明的就是,由于LGPL是在Qt4.5这个版本里面才引入的,所以之前的Qt版本,4.4或者3.x的版本,并不提供LGPL协议,是不可逆的。同时未来发布的Qt版本,就一直会提供三种不同的授权协议版本。

下面有一些链接,有兴趣想深入了解这些授权协议的同学,可以学习学习

GPL协议原文 - http://www.gnu.org/copyleft/gpl.html
GPL协议中文译文 - http://bergwolf.googlepages.com/gplv3_zh
LGPL协议原文 - http://www.gnu.org/copyleft/lesser.html
LGPL协议中文译文 - http://www.thebigfly.com/gnu/lgpl/lgpl-v3.php
58种不同的开源协议 - http://www.fsf.org/licensing/licenses/
什么是动态链接 - http://zh.wikipedia.org/wiki/%E5%8A%A8%E6%80%81%E9%93%BE%E6%8E%A5%E5%BA%93
官方声明 - http://www.qtsoftware.com/about/news/lgpl-license-option-added-to-qt
官方Q&A - http://www.qtsoftware.com/about/licensing/frequently-asked-questions

/**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtNetwork module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 3 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL3 included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 3 requirements ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 2.0 or (at your option) the GNU General ** Public license version 3 or any later version approved by the KDE Free ** Qt Foundation. The licenses are as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 ** included in the packaging of this file. Please review the following ** information to ensure the GNU General Public License requirements will ** be met: https://www.gnu.org/licenses/gpl-2.0.html and ** https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #ifndef QUDPSOCKET_H #define QUDPSOCKET_H #include <QtNetwork/qtnetworkglobal.h> #include <QtNetwork/qabstractsocket.h> #include <QtNetwork/qhostaddress.h> QT_BEGIN_NAMESPACE #ifndef QT_NO_UDPSOCKET class QNetworkDatagram; class QNetworkInterface; class QUdpSocketPrivate; class Q_NETWORK_EXPORT QUdpSocket : public QAbstractSocket { Q_OBJECT public: explicit QUdpSocket(QObject *parent = nullptr); virtual ~QUdpSocket(); #ifndef QT_NO_NETWORKINTERFACE bool joinMulticastGroup(const QHostAddress &groupAddress); bool joinMulticastGroup(const QHostAddress &groupAddress, const QNetworkInterface &iface); bool leaveMulticastGroup(const QHostAddress &groupAddress); bool leaveMulticastGroup(const QHostAddress &groupAddress, const QNetworkInterface &iface); QNetworkInterface multicastInterface() const; void setMulticastInterface(const QNetworkInterface &iface); #endif bool hasPendingDatagrams() const; qint64 pendingDatagramSize() const; QNetworkDatagram receiveDatagram(qint64 maxSize = -1); qint64 readDatagram(char *data, qint64 maxlen, QHostAddress *host = nullptr, quint16 *port = nullptr); qint64 writeDatagram(const QNetworkDatagram &datagram); qint64 writeDatagram(const char *data, qint64 len, const QHostAddress &host, quint16 port); inline qint64 writeDatagram(const QByteArray &datagram, const QHostAddress &host, quint16 port) { return writeDatagram(datagram.constData(), datagram.size(), host, port); } private: Q_DISABLE_COPY(QUdpSocket) Q_DECLARE_PRIVATE(QUdpSocket) }; #endif // QT_NO_UDPSOCKET QT_END_NAMESPACE #endif // QUDPSOCKET_H #include "multicastreceiver.h" #include <QNetworkDatagram> MulticastReceiver::MulticastReceiver(QObject *parent) : QObject(parent), socket(new QUdpSocket(this)), joined(false) { connect(socket, &QUdpSocket::readyRead, this, &MulticastReceiver::processPendingDatagrams); } MulticastReceiver::~MulticastReceiver() { if (joined) { leaveMulticastGroup(); } } bool MulticastReceiver::joinMulticastGroup(const QHostAddress &groupAddress, quint16 port, const QNetworkInterface &interface) { if (joined) { leaveMulticastGroup(); } // 绑定到指定端口 if (!socket->bind(QHostAddress::AnyIPv4, port, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint)) { return false; } // 加入组播组 if (!socket->joinMulticastGroup(groupAddress, interface)) { socket->close(); return false; } this->groupAddress = groupAddress; joined = true; return true; } void MulticastReceiver::leaveMulticastGroup() { if (joined) { socket->leaveMulticastGroup(groupAddress); socket->close(); joined = false; } } bool MulticastReceiver::isJoined() const { return joined; } void MulticastReceiver::processPendingDatagrams() { while (socket->hasPendingDatagrams()) { QNetworkDatagram datagram = socket->receiveDatagram(); if (datagram.isValid()) { emit dataReceived(datagram.data(), datagram.senderAddress(), QDateTime::currentDateTime()); } } } 为什么再加入组播的时候 提示未知错误,怎么解决
最新发布
09-21
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值