Qt 4.8.2 With GCC 4.7.0.1 Keeps Crashing

前端 未结 2 1312
太阳男子
太阳男子 2021-01-15 01:08

I\'ve downloaded Qt 4.8.2 library, Qt Creator 2.5.2, and manually installed MingW with w32api version 3.13 and GCC/g++ version 4.7.0.1. My OS is Windows 7 Ultimate x64.

2条回答
  •  旧巷少年郎
    2021-01-15 01:59

    You should build Qt with the MinGW compiler you're using to build your application. GCC is generally less sensitive to binary compatibility issues than MSVC is, but Qt is a big, complex framework library. If anything would expose those kinds of issues, Qt would probably be on the short list.

    Building Qt is pretty straightforward, but it takes a lot of time and there always seems to be two or three patches I need to make to get things to build successfully.

    The last time I built Qt (4.7.3) with MinGW, I had to make the following patches - I'm not sure whether they will still apply to Qt 4.8:

    • make sure not to enable C++11 mode in the compiler - there are several macros with concatenated string literals that break under the new C++11 extended literal syntax
    • there is a problem with how some distributions of MinGW incorporate the Microsoft extensions to float.h - I had to sometimes had to add the line:

      #include_next 
      

      to the end of the MinGW-specific float.h so the generic GCC float.h would get processed properly. I had to do this for nuwen 4.7.0 lib/gcc/i686-pc-mingw32/4.7.0/include/float.h and TDM 4.6.1 32-bit distro lib/gcc/mingw32/4.6.1/include/float.h (the 64-bit distro of TDM didn't need this patch).

    • patch qmake\Makefile.win32-g++ and qmake\Makefile.win32-g++-sh to remove the -static-libstdc++ option that GCC doesn't recognize (and now errors out on instead of ignores)

    • patch mkspecs/win32-g++/qmake.conf to move the -Wl, in the QMAKE_LFLAGS_EXCEPTIONS_ON macro to its proper place in QMAKE_FLAGS:

      QMAKE_LFLAGS        = -Wl,-enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc
      QMAKE_LFLAGS_EXCEPTIONS_ON = -mthreads
      
    • copy make.exe to mingw32-make.exe in MinGW's bin directory if there's not already a mingw32-make.exe

    Then building Qt consists of:

      set QTDIR=  # where configure.exe is
      set PATH=%QTDIR%\bin;c:\MinGW\bin;%PATH%
      set INCLUDE=
      set LIB=
      cd %QTDIR%
    
      mingw32-make confclean    # (this should fail the first time, since there's nothing to clean)
      configure.exe -opensource -debug-and-release -nomake examples -nomake demos -nomake tests -platform win32-g++  # and accept the GPL license
      mingw32-make
    

    This takes a while... hopefully nothing else will need patching.

提交回复
热议问题