Qt 5的静态编译在mingw下参考off64_t失败

Posted

技术标签:

【中文标题】Qt 5的静态编译在mingw下参考off64_t失败【英文标题】:Static compilation of Qt 5 fails under mingw with reference to off64_t 【发布时间】:2013-11-21 16:15:17 【问题描述】:

我尝试制作静态 qt,但在 mingw-make 期间出错。这是错误文本。

static\qhttpnetworkreply.o access\qhttpnetworkreply.cpp
In file included from ..\..\mkspecs\win32-g++/qplatformdefs.h:56:0,
             from access\qhttpnetworkreply_p.h:55,
             from access\qhttpnetworkreply.cpp:42:
c:\mingw\include\io.h:301:14: error: 'off64_t' does not name a type
__CRT_INLINE off64_t lseek64 (int, off64_t, int);
           ^
c:\mingw\include\io.h:302:14: error: 'off64_t' does not name a type
__CRT_INLINE off64_t lseek64 (int fd, off64_t offset, int whence) 
          ^
Makefile.Debug:8214: recipe for target '.obj/debug_static/qhttpnetworkreply.o' f   ailed
mingw32-make[3]: *** [.obj/debug_static/qhttpnetworkreply.o] Error 1
mingw32-make[3]: Leaving directory 'C:/Qt/Qt5.1.1/5.1.1/Src/qtbase/src/network'
Makefile:38: recipe for target 'debug-all' failed
mingw32-make[2]: *** [debug-all] Error 2
mingw32-make[2]: Leaving directory 'C:/Qt/Qt5.1.1/5.1.1/Src/qtbase/src/network'
Makefile:182: recipe for target 'sub-network-make_first' failed
mingw32-make[1]: *** [sub-network-make_first] Error 2
mingw32-make[1]: Leaving directory 'C:/Qt/Qt5.1.1/5.1.1/Src/qtbase/src'
Makefile:41: recipe for target 'sub-src-make_first' failed
mingw32-make: *** [sub-src-make_first] Error 2
C:\Qt\Qt5.1.1\5.1.1\Src\qtbase>

我使用的是 Windows 8.1。我按照一个说明中的步骤进行操作。

【问题讨论】:

【参考方案1】:

这是 MinGW 中的一些错误,当使用 -ansi、-std=c++11、-std=c++03 和 -std=c++98 之一时。 在文件 MinGW dir/include/io.h 中替换

__CRT_INLINE off64_t lseek64 (int, off64_t, int);
__CRT_INLINE off64_t lseek64 (int fd, off64_t offset, int whence) 

__CRT_INLINE _off64_t lseek64 (int, _off64_t, int);
__CRT_INLINE _off64_t lseek64 (int fd, _off64_t offset, int whence) 

【讨论】:

以上是关于Qt 5的静态编译在mingw下参考off64_t失败的主要内容,如果未能解决你的问题,请参考以下文章

opencv4.5.5+qt5.15.2+vtk9.1+mingw81_64编译记录

opencv4.5.5+qt5.15.2+vtk9.1+mingw81_64编译记录

win下qt编译librdkafka

QtCreator 静态编译

QT下opencv的编译和使用

Qt 静态编译(5.15.2 MinGW 32-bit)