qt

推荐用dwarf版的i686-w64-mingw编译
i686-4.8.1-release-win32-dwarf-rt_v3-rev2.7z\mingw32\opt\x32-480-posix-dwarf-r2

注意5个路径宏(环境变量)
MINGW_HOME=D:\MinGW\i686-w64-mingw32
C_INCLUDE_PATH=%MINGW_HOME%\include;//不可加这个路径否则头文件优先级冲突%MINGW_HOME%\i686-w64-mingw32\include;
CPLUS_INCLUDE_PATH=%MINGW_HOME%\include;//不可加这个路径否则头文件优先级冲突%MINGW_HOME%\i686-w64-mingw32\include;
LD_LIBRARY_PATH=%MINGW_HOME%\bin;//不可加这个路径否则头文件优先级冲突%MINGW_HOME%\i686-w64-mingw32\bin;
LIBRARY_PATH=%MINGW_HOME%\lib;//不可加这个路径否则头文件优先级冲突%MINGW_HOME%\i686-w64-mingw32\lib;

安装ruby1.90+和perl,python2.7

依赖zlib 要确定mingw安装了 zlib的
qt编译需要用到python

release webkit时会需要win_flex.exe bison.exe等
需要将
D:\CLib\Qt_everywhere_520rc1\gnuwin32
目录加到环境变量path最前面,防止git/bin/bison.exe和gnuwin32/bison.exe冲突出错

//-- 如你不想自己配置mingw环境, 也可以使用官方提供的版本中的mingw
qt5.2.0beta1版(-符号,非--符号)
先下载mingw的编译成功版(shared)带mingw,安装msys配置mingw
然后下载源码编译静态版 --//

./configure
-prefix D:/CLib/Qt/Qt5.2.0-rc1/5.2.0-rc1/mingw48_32_static
#路径只能是上面的写法,不能用/D/CLib或D:\\CLib或D:\CLib
#否则qtcreator不能识别这种路径,显示获取qt版本失败
#D:/CLib/Qt/Qt5.2.0-rc1/5.2.0-rc1/mingw48_32_static
#-prefix第一次生成错误则需还原qtbase目录重新执行./configure,
#不还原qtbase目录就重生成的qmake(-query)路径会始终有错误
-debug #跟release要单独使用编译
-release
-platform win32-g++
#必须设置交叉编译属性,否则qtcreator不识别
-static
-nomake examples
-nomake tests
-no-rpath
#mingw平台不支持rpath
-continue #不建议使用,反而导致错误难以发现,而反复失败
-icu #要用webkit和全集unicode要编译icu-unicode(icu4c)
#错误继续,除非有错误始终过不了,不然不要加
如:-编译需先编译debug在release版,以防留下较大文件的debug版exe
ICU通过检测需要libs*.a libs*d.a 但是编译时还需要lib*.a (release的bug)

//debug版可能检测不到icu需要加上continue参数
./configure -prefix D:/CLib/Qt/Qt5.2.0-rc1/5.2.0-rc1/mingw48_32_static_icu -platform win32-g++ -release -static -confirm-license -qt-sql-odbc -nomake examples -nomake tests -no-rpath -icu -skip webkit -skip webkit-examples
./configure -prefix D:/CLib/Qt/Qt5.2.0-rc1/5.2.0-rc1/mingw48_32_stared_icu -platform win32-g++ -release -shared -confirm-license -qt-sql-odbc -nomake examples -nomake tests -no-rpath -icu -skip webkit -skip webkit-examples
./configure -prefix D:/CLib/Qt/Qt5.2.0-rc1/5.2.0-rc1/mingw48_32_static -platform win32-g++ -debug -static -confirm-license -qt-sql-odbc -nomake examples -nomake tests -no-rpath -no-icu -skip webkit -skip webkit-examples
./configure -prefix D:/CLib/Qt/Qt5.2.0-rc1/5.2.0-rc1/mingw48_32_static -platform win32-g++ -release -static -confirm-license -qt-sql-odbc -nomake examples -nomake tests -no-rpath -no-icu -skip webkit -skip webkit-examples
./configure -prefix D:/CLib/Qt/Qt5.2.0-rc1/5.2.0-rc1/mingw48_32_shared -platform win32-g++ -debug -shared -confirm-license -qt-sql-odbc -nomake examples -nomake tests -no-rpath -no_icu -skip webkit -skip webkit-examples
./configure -prefix D:/CLib/Qt/Qt5.2.0-rc1/5.2.0-rc1/mingw48_32_shared -platform win32-g++ -release -shared -confirm-license -qt-sql-odbc -nomake examples -nomake tests -no-rpath -no-icu -skip webkit -skip webkit-examples
./configure执行后需要 atbase/bin/qmake.exe -query查看路径情况

路径不对qtcreator将不能识别
以下情况也不能识别:
缺少bin/libQt5Cored.dll【shared】或lib/libQt5Cored.a【static】(都要有debug版)

编辑器选责输入o(c商业,o开源)
LGPL选输入yes


执行下面命令,等待2~3个小时时间
make
make install

反安装:make uninstall
清除编译:make clean

如果修改./configure参数(特别是--prefix)的编译则需重新复制进纯净qtbase/目录,反之可直接make

=======================================================
如果jsc::yarr::..出错
修改
qtdeclarative/YarrInterpreter.cpp
qtdeclarative/YarrPattern.cpp
qtscript/RegexCompiler.cpp
qtwebkit/YarrPattern.cpp
下的一众:
CharacterClass* newlineCreate();
。。。
CharacterClass* nonwordcharCreate();

为一致:
inline CharacterClass* newlineCreate()
{
。。。
}

=======================================================
如果'off64_t' does not name a type错误
这是新版mingw的io.h文件新定义的变量 在<sys/types.h>中
缺少的文件都加上这个头文件
则修改/mingw/sys/types.h中和 /mingw/mingw32/sys/types.h中第146行处
#define _OFF64_T_ 之后加上
#define MY_XBUG_OFF64_T_
修改/mingw/sys/io.h中和 /mingw/mingw32/sys/io.h中第300行处
修改为
#ifndef __NO_MINGW_LFS
#if defined(_OFF64_T_) && !defined(MY_XBUG_OFF64_T_)
__CRT_INLINE _off64_t lseek64 (int, _off64_t, int);
__CRT_INLINE _off64_t lseek64 (int fd, _off64_t offset, int whence) {
  return _lseeki64(fd, (__int64) offset, whence);
}
#else
__CRT_INLINE off64_t lseek64 (int, off64_t, int);
__CRT_INLINE off64_t lseek64 (int fd, off64_t offset, int whence) {
  return _lseeki64(fd, (long long) offset, whence);
}
#endif
#endif

=======================================================
如果出现QT_PLUGIN_PATH不是内部或外部命
这是项目文件环境变量值解析的问题
修改qtbase/mkspecs/features/qt_functions.prf

defineTest(qtAddToolEnv)(大概218行)中的
$$1 = "$$val $$eval($$1)" (大概241行)

!contains(QMAKE_HOST.os, Windows){
    $$1 = "$$val $$eval($$1)"
}

=======================================================
如果如下错误:
qopenglversionfunctions.h:785:43: error: expected
unqualified-id before ')' token
void (QOPENGLF_APIENTRYP MemoryBarrier)(GLbitfield barriers);
则在/mingw/sys/winnt.h中和 /mingw/mingw32/sys/winnt.h中的
MemoryBarrier定义改为:
#if _WIN32_WINNT >= _WIN32_WINNT_VISTA
# if defined(_AMD64_) || defined(__X86_64)
#  define MemoryBarrier __faststorefence

# elif defined(_IA64_)

#  define MemoryBarrier __mf
# else

   void __mingworg_MemoryBarrier(void);
#  define MemoryBarrier __mingworg_MemoryBarrier
# endif

//<< my_xbug
#elif defined __GNUC__ && __GNUC__ >= 4 && __GNUC_MINOR__ >= 4

# define MemoryBarrier __sync_synchronize
//>> my_xbug
#else

# define MemoryBarrier
#endif

======================================================
如果如下错误:
d:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot fin
d -lsicuind
d:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot fin
d -lsicuucd
d:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot fin
d -lsicudtd
静态release版会提示找不到-licuin -licuuc -licudt则需要libsicuin.a复制为libicuin.a
则需要icu-unicode需要debug和release双版本 且static为libs*.a而debug命名加libs*d.a
shared为lib*.a而debug命名加lib*d.a

======================================================
如下一堆WINDOWS错误(由于mignw4.81的头文件包含顺序不当,会造成错误回环):
In file included from d:\mingw\include\objbase.h:95:0,
                 from d:\mingw\include\ole2.h:31,
                 from d:\mingw\include\windows.h:101,
                 from d:\mingw\include\rpc.h:27,
                 from d:\mingw\include\wtypes.h:29,
                 from platformdefs.h:45,
                 from main.cpp:43:
d:\mingw\include\objidl.h:69:2: error: 'LPOLESTR' does not name a type
  LPOLESTR pwcsName;
  ^
d:\mingw\include\objidl.h:113:9: error: 'OLECHAR' does not name a type
 typedef OLECHAR **SNB;
         ^
d:\mingw\include\objidl.h:259:2: error: 'OLECHAR' does not name a type
  OLECHAR rgString[1];
  ^
d:\mingw\include\objidl.h:302:2: error: 'CY' does not name a type
  CY *pElems;
  ^
  。。。
要修改这个错误就要加个宏防止错误回环,修改/mingw/wtypes.h的
#ifndef MY_XBUG_WTYPES_H
#define MY_XBUG_WTYPES_H
#ifdef __cplusplus
extern "C" {
#endif
。。。。。。。。。。。。。。。。。
#ifdef __cplusplus
}
#endif
#endif

在重复的文件里面,引用wtypes.h之前修改为如下
(如:/mingw/objbase.h 93行):

#if !defined(MY_XBUG_WTYPES_H) && defined(_WTYPES_H)
#undef _WTYPES_H
#endif
#include <wtypes.h>


==========================================================
//一堆windows定义错误,需要将系统默认的最低win2000提升为最低xp

修改/mingw/sdkddkver.h之下的系统默认值(150行后)
#    ifdef _WARN_DEFAULTS
//#    warning _WIN32_WINNT is defaulting to _WIN32_WINNT_WIN2K
//     MY_XBUG_DEFAULT_WIN32
#      warning _WIN32_WINNT is defaulting to _WIN32_WINNT_WINXP
#    endif
//#  define _WIN32_WINNT _WIN32_WINNT_WIN2K
//   MY_XBUG_DEFAULT_WIN32
#    define _WIN32_WINNT _WIN32_WINNT_WINXP

单独修改的:
qtbase/src/plugins/platforms/windows/qwindowsfontengine.cpp 首 0x0500 改为 0x0501
qtbase/src/corelib/io/qfilesystemiterator_win.cpp 首 0x0500 改为 0x0501

================================================================
错误:redefinition of 'struct SHARDAPPIDINFOLINK'
重复定义SHARDAPPIDINFOLINK
修改qtwinextras\src\winextras\winshobjidl_p.h的定义处加上NTDDI_VERSION判断
#       if defined(_SHLOBJ_H_) || (!defined(_SHLOBJ_H_) && NTDDI_VERSION < 0x06010000)
...
#       endif


================================================================
lralease崩溃是使用icu导致不能获取系统编码(US-ASCII)在QTextStream销毁时
导致错误,修改qtbase\src\corelib\io\qtextstream.cpp的第500行左右
QTextStreamPrivate::flushWriteBuffer()
{
........................

#ifndef QT_NO_TEXTCODEC
    if (!codec){
        codec = QTextCodec::codecForLocale();
    }
#if defined (QTEXTSTREAM_DEBUG)
    qDebug("QTextStreamPrivate::flushWriteBuffer(), using %s codec (%s generating BOM)",
           codec->name().constData(), writeConverterState.flags & QTextCodec::IgnoreHeader ? "not" : "");
#endif
    // convert from unicode to raw data
    QChar* qdata = writeBuffer.data();
    int sz = writeBuffer.size();
    QByteArray data;
    if (codec)
        data = codec->fromUnicode(qdata, sz, &writeConverterState);
    else
        data = writeBuffer.toLocal8Bit();
#else
    QByteArray data = writeBuffer.toLocal8Bit();
#endif
    writeBuffer.clear();

........................
}

==============================================================
JS_EXPORT_PRIVATE宏错误 是由于Source\JavaScriptCore\下congfig.h和Source\WTF\下的config.h冲突
Source\JavaScriptCore\下的所有代码实际使用了Source\WTF\下的config.h因此需在Source\WTF\config.h
加上
#if !defined(BUILDING_WTF)
#include "JSExportMacros.h"
#endif
这句以是两个config.h个文件基本一致(不加JSExportMacros.h就会出现宏错误)

转载于:https://my.oschina.net/rechy/blog/189724

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值