使用vc(vs2008)编译Qt5.4

使用vc(vs2008)编译Qt5.4


官方的Qt
只有vc10以上的版本
若是想vc9 只能自己编译
so 开始干
搜索资料
1)vc9不能支持webkit的编译 直接删除掉
2)有部分地方 vc9默认支持LONG转ULONG 需要自己改代码
3)需要OPENSSL
4)需要python3.4.3
5)需要activePerl开工
1。下载安装activeperl
2。下载安装python3.4.3
3。编译openssl 0.9.8k
perl Configure VC-WIN32 –prefix=C:\Build-OpenSSL-VC9-32
ms\do_ms
nmake -f ms\nt.mak  
nmake -f ms\nt.mak install

4。开始config Qt5 一个bat搞定

复制代码

  1. cd /d "C:\Program Files\7-Zip"

    call "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat"

    if exist E:\qt-everywhere-opensource-src-5.4.0 (
    echo "QT FIles exists"
    ) else (
    REM 7z x D:\Qt\qt-everywhere-opensource-src-5.4.0.zip -oE:\
    echo "COPY Qt 5.4.0 Source"
    xcopy %~dp0\qt5.4-source E:\qt-everywhere-opensource-src-5.4.0 /s /e /I
    )

    rd /s /q E:\qt-everywhere-opensource-src-5.4.0\qtwebkit
    rd /s /q E:\qt-everywhere-opensource-src-5.4.0\qtwebkit-examples

    copy /y %~dp0\dscamerasession.cpp  E:\qt-everywhere-opensource-src-5.4.0\qtmultimedia\src\plugins\directshow\camera

    cd /d E:\qt-everywhere-opensource-src-5.4.0
    set PATH=C:\Python34;C:\Program Files\7-Zip;%CD%\qtbase\bin;%PATH%
    set QTDIR=C:\Qt\5.4.0

    configure.bat -developer-build -opensource -nomake examples -nomake tests -mp -confirm-license -opengl desktop -no-icu -skip qtserialport -platform win32-msvc2008 -openssl-linked OPENSSL_LIBS="-lssleay32 -llibeay32" -I "C:\Python34\include" -I C:\Build-OpenSSL-VC9-32\include -L C:\Build-OpenSSL-VC9-32\lib -L "C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib" -L C:\Python34\libs -l Gdi32 -l User32  -prefix C:\Qt\5.4.0 -mp

    nmake

    nmake install

    pause


附上文中改掉的cpp文件 找到对应位置自行修改
文件路径为qtmultimedia\src\plugins\directshow\camera\dscamerasession.cpp

复制代码

  1. STDMETHODIMP_(ULONG) AddRef()
        {
            #if _MSC_VER==1500
                volatile LONG *p_ref=reinterpret_cast<volatile LONG *>(&m_ref);
                return InterlockedIncrement(p_ref);
            #else
                return InterlockedIncrement(&m_ref);
            #endif
        }


        STDMETHODIMP_(ULONG) Release()
        {
            #if _MSC_VER==1500
                volatile LONG *p_ref=reinterpret_cast<volatile LONG *>(&m_ref);
                ULONG ref = InterlockedDecrement(p_ref);
            #else
                ULONG ref = InterlockedDecrement(&m_ref);
            #endif
            if (ref == 0)
                delete this;
            return ref;
        }

完工
从此告别恼人的xp问题

 

 

按照你的方法编译5.5,部分模块编译成功,一部分出错(qttools 出错,其他依赖它的模块也编译不过去),错误如下,有谁知道什么原因?查了很久没查到什么原因导致的。

D:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\xutility(263) : error C2678: 二进制“<”: 没有找到接受“const QString”类型的左操作数的运算符(或没有可接受的转换)
        f:\qt\qt5\qtbase\include\qtcore\../../src/corelib/tools/qchar.h(533): 可能是“bool operator <(QChar,QChar)”[通过使用参数相关的查找找到]
        f:\qt\qt5\qtbase\include\qtcore\../../src/corelib/tools/qbytearray.h(599): 或       “bool operator <(const QByteArray &,const QByteArray &)”[使用参数相关的查找找到]
        f:\qt\qt5\qtbase\include\qtcore\../../src/corelib/tools/qbytearray.h(601): 或       “bool operator <(const QByteArray &,const char *)”[使用参数相关的查找找到]
        f:\qt\qt5\qtbase\include\qtcore\../../src/corelib/tools/qbytearray.h(603): 或       “bool operator <(const char *,const QByteArray &)”[使用参数相关的查找找到]
        f:\qt\qt5\qtbase\include\qtcore\../../src/corelib/tools/qstring.h(625): 或       “bool operator <(const QString &,const QString &)”[使用参数相关的查找找到]
        f:\qt\qt5\qtbase\include\qtcore\../../src/corelib/tools/qstring.h(694): 或       “bool operator <(const char *,const QString &)”[使用参数相关的查找找到]
        f:\qt\qt5\qtbase\include\qtcore\../../src/corelib/tools/qstring.h(701): 或       “bool operator <(const char *,const QStringRef &)”[使用参数相关的查找找到]
        f:\qt\qt5\qtbase\include\qtcore\../../src/corelib/tools/qstring.h(1121): 或       “bool operator <(QLatin1String,QLatin1String)”[使用参数相关的查找找到]
        f:\qt\qt5\qtbase\include\qtcore\../../src/corelib/tools/qstring.h(1178): 或       “bool operator <(const char *,QLatin1String)”[使用参数相关的查找找到]
        f:\qt\qt5\qtbase\include\qtcore\../../src/corelib/tools/qstring.h(1504): 或       “bool operator <(const QStringRef &,const QStringRef &)”[使用参数相关的查找找到]
        f:\qt\qt5\qtbase\include\qtcore\../../src/corelib/tools/qcollator.h(72): 或       “bool operator <(const QCollatorSortKey &,const QCollatorSortKey &)”[使用参数相关的查找找到]
        f:\qt\qt5\qtbase\include\qtcore\../../src/corelib/tools/qelapsedtimer.h(80): 或       “bool operator <(const QElapsedTimer &,const QElapsedTimer &) throw()”[使用参数相关的查找找到]
        .\qhelpsearchindexwriter_clucene.cpp(329): 或       “bool fulltextsearch::clucene::operator <(const fulltextsearch::clucene::QTextHtmlEntity &,const QString &)”[使用参数相关的查找找到]
        f:\qt\qt5\qtbase\include\qtcore\../../src/corelib/tools/qstring.h(632): 或       “bool QString::operator <(QLatin1String) const”
        f:\qt\qt5\qtbase\include\qtcore\../../src/corelib/tools/qstring.h(680): 或       “bool QString::operator <(const char *) const”
        f:\qt\qt5\qtbase\include\qtcore\../../src/corelib/tools/qstring.h(687): 或       “bool QString::operator <(const QByteArray &) const”

 

由于std::lower_bound导致的问题,已解决,方法如下:
在qttools\src\assistant\help\qhelpsearchindexwriter_clucene.cpp增加如下代码:

复制代码

  1. #if defined(Q_CC_MSVC) && _MSC_VER < 1600
    //The STL implementation of MSVC 2008 requires the definitions
    static bool operator<(const QTextHtmlEntity &entity1, const QTextHtmlEntity &entity2)
    {
        return QLatin1String(entity1.name) < QLatin1String(entity2.name);
    }

    static bool operator<(const QString &entityStr, const QTextHtmlEntity &entity)
    {
        return entityStr < QLatin1String(entity.name);
    }
    #endif

在qt3d\src\render\backend\jobs\renderviewjobutils_p.h修改如下代码:

复制代码

  1. struct ParameterInfo
    {
        ParameterInfo(const QString &name = QString(), const QVariant &value = QVariant())
            : name(name)
            , value(value)
        {}

        QString name;
        QVariant value;

        bool operator<(const QString &otherName) const
        {
            return name < otherName;
        }
        bool operator<(const ParameterInfo &other) const
        {
            return name < other.name;
        }
    };

    #if defined(Q_CC_MSVC) && _MSC_VER < 1600
    //The STL implementation of MSVC 2008 requires the definitions
    static bool operator<(const QString &name, const ParameterInfo &pi)
    {
        return name < pi.name;
    }
    #endif


 


唯一的缺陷是c++11支持不够好

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

lst0426

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值