Qt 4.8.2 With GCC 4.7.0.1 Keeps Crashing

前端 未结 2 1309
太阳男子
太阳男子 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:58

    I also got this problem. I'm a Qt n00b and tought, when installing Qt-libraries, that "well I already have Mingw installed so I skip installing the Mingw that comes with Qt". That gave me prolems. When installing mingw that came with Qt everything worked ok.

    So my advice to anyone googling to this question (like I did) is to instead of using your already installed Mingw, install the one with Qt and use that (otherwise you have to build the Qt libraries within your Mingw, like the answer from Michael Burr)

    0 讨论(0)
  • 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 <float.h>
      

      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=<location of Qt source directory>  # 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.

    0 讨论(0)
提交回复
热议问题