商业版源代码包:qt-win-commercial-src-4.2.2.zip,由于涉及盗版,不宜公开下载。
1、解压
将源码包解压到c:/下,重命令文件夹为qt4。
2、license文件
在你的当前用户文件夹下(如:C:/Documents and Settings/Administrator)建立文件.qt-license.
编辑之,贴入以下内容(其中的LicenseKeyExt不方便在此提供,大家网上应该可以搜到)
[code]==================================
LicenseKeyExt="xxxx-xxx-xxx-xxx-xxxx-xxxx-xxxx"
LicenseId="0"
Licensee="Any Name"
ProductType="qt-enterprise"
LicenseType="Commercical"
ExpiriDate=3002-09-21
================================== [/code]
3、环境变量
(不知道是不是我的VS太笨,居然没有设置环境变量,只好自己设了)
打开VS目录下common7/tools目录下的vsvars32.bat文件,然后右键我的电脑->属性->高级->环境变量,参考vsvars32.bat文件来设置环境变量。
以下是我修改后的环境变量:
[code]
@SET VSINSTALLDIR=C:/Program Files/Microsoft Visual Studio 8
@SET VCINSTALLDIR=C:/Program Files/Microsoft Visual Studio 8/VC
@SET FrameworkDir=C:/WINDOWS/Microsoft.NET/Framework
@SET FrameworkVersion=v2.0.50727
@SET FrameworkSDKDir=C:/Program Files/Microsoft Visual Studio 8/SDK/v2.0
@set DevEnvDir=C:/Program Files/Microsoft Visual Studio 8/Common7/IDE
@set PATH=C:/Program Files/Microsoft Visual Studio 8/Common7/IDE;C:/Program Files/Microsoft Visual Studio 8/VC/BIN;C:/Program Files/Microsoft Visual Studio 8/Common7/Tools;C:/Program Files/Microsoft Visual Studio 8/Common7/Tools/bin;C:/Program Files/Microsoft Visual Studio 8/VC/PlatformSDK/bin;C:/Program Files/Microsoft Visual Studio 8/SDK/v2.0/bin;C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727;C:/Program Files/Microsoft Visual Studio 8/VC/VCPackages;c:/qt4
[b]@rem 注意这里要有qt4的路径,另外注意,别忘了把你原来的Path变量加进来[/b]
@set INCLUDE=C:/Program Files/Microsoft Visual Studio 8/VC/ATLMFC/INCLUDE;C:/Program Files/Microsoft Visual Studio 8/VC/INCLUDE;C:/Program Files/Microsoft Visual Studio 8/VC/PlatformSDK/include
@set LIB=C:/Program Files/Microsoft Visual Studio 8/VC/ATLMFC/LIB;C:/Program Files/Microsoft Visual Studio 8/VC/LIB;C:/Program Files/Microsoft Visual Studio 8/VC/PlatformSDK/lib;C:/Program Files/Microsoft Visual Studio 8/SDK/v2.0/lib
@set LIBPATH=C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727;C:/Program Files/Microsoft Visual Studio 8/VC/ATLMFC/LIB
[/code]
4、修改源代码
由于vs2005sp1引入了一个BUG,导致源代码无法顺利编译。请参考http://support.microsoft.com/kb/928957
修改C:/qt4/src/corelib/tools目录下有问题的文件qhash.h和qmap.h
以下以qhash.h为例
将
[code]class QMultiHash : public QHash<Key, T>
{
public:
QMultiHash() {}
QMultiHash(const QHash<Key, T> &other) : QHash<Key, T>(other) {}
inline typename QHash<Key, T>::iterator replace(const Key &key, const T &value); // 有问题的代码
inline typename QHash<Key, T>::iterator insert(const Key &key, const T &value); //有问题的代码
inline QMultiHash &operator+=(const QMultiHash &other)
{ unite(other); return *this; }
inline QMultiHash operator+(const QMultiHash &other) const
{ QMultiHash result = *this; result += other; return result; }
private:
T &operator[](const Key &key);
const T operator[](const Key &key) const;
};
template <class Key, class T>
Q_INLINE_TEMPLATE Q_TYPENAME QHash<Key, T>::iterator QMultiHash<Key, T>::replace(const Key &akey, const T &avalue) // 这行也需要修改
{ return QHash<Key, T>::insert(akey, avalue); }
template <class Key, class T>
Q_INLINE_TEMPLATE Q_TYPENAME QHash<Key, T>::iterator QMultiHash<Key, T>::insert(const Key &akey, const T &avalue) // 这行也需要修改
{ return QHash<Key, T>::insertMulti(akey, avalue); }[/code]
修改为:
[code]class QMultiHash : public QHash<Key, T>
{
public:
QMultiHash() {}
QMultiHash(const QHash<Key, T> &other) : QHash<Key, T>(other) {}
typedef QHash<Key, T>::iterator QHash_iterator; // 增加一个typedef
inline typename QHash_iterator replace(const Key &key, const T &value); // 在整个类中都使用这个typedef
inline typename QHash_iterator insert(const Key &key, const T &value); // 在整个类中都使用这个typedef
inline QMultiHash &operator+=(const QMultiHash &other)
{ unite(other); return *this; }
inline QMultiHash operator+(const QMultiHash &other) const
{ QMultiHash result = *this; result += other; return result; }
private:
T &operator[](const Key &key);
const T operator[](const Key &key) const;
};
template <class Key, class T>
Q_INLINE_TEMPLATE Q_TYPENAME QMultiHash<Key, T>::QHash_iterator QMultiHash<Key, T>::replace(const Key &akey, const T &avalue) // 在整个类中都使用这个typedef
{ return QHash<Key, T>::insert(akey, avalue); }
template <class Key, class T>
Q_INLINE_TEMPLATE Q_TYPENAME QMultiHash<Key, T>::QHash_iterator QMultiHash<Key, T>::insert(const Key &akey, const T &avalue)// 在整个类中都使用这个typedef
{ return QHash<Key, T>::insertMulti(akey, avalue); }[/code]
OK,大功告成
configure
nmake
祝你成功!
LicenseID="4444"
Licensee="StarDancer"
LicenseKeyExt=FGKX-RM5-F4M-2CX-3P5X-HGM8X-2B52