[英]Improper mingw.thread.h header file installation
我最初問了一個關於我讓 #include 頭文件正常運行的問題的問題。 C++ 多線程錯誤。 具體來說,我收到“'thread' 未在此范圍內聲明”的錯誤。 我開始懷疑我最初的假設是否錯誤地安裝了 mingw.thread.h 頭文件(位於此處: https : //github.com/meganz/mingw-std-threads )。 這似乎有助於解決很多人的這些問題,
有人可以提供有關如何正確安裝此文件的說明嗎?
這些是我在終端上運行 gcc -v 時的結果:
使用內置規范。
COLLECT_GCC=c:\MinGW\bin\gcc.exe
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/6.3.0/lto-wrapper.exe
Target: mingw32
Configured with: ../src/gcc-6.3.0/configure --build=x86_64-pc-linux-gnu --host=mingw32 --target=mingw32 --with-gmp=/mingw --with-mpfr --with-mpc=/mingw --with-isl=/mingw --prefix=/mingw --disable-win32-registry --with-arch=i586 --with-tune=generic --enable-languages=c,c++,objc,obj-c++,fortran,ada --with-pkgversion='MinGW.org GCC-6.3.0-1' --enable-static --enable-shared --enable-threads --with-dwarf2 --disable-sjlj-exceptions --enable-version-specific-runtime-libs --with-libiconv-prefix=/mingw --with-libintl-prefix=/mingw --enable-libstdcxx-debug --enable-libgomp --disable-libvtv --enable-nls
Thread model: win32
gcc version 6.3.0 (MinGW.org GCC-6.3.0-1)
編輯:為了提供幫助,當我包含“mingw.thread.h”並編譯時,出現以下錯誤:
錯誤:#error 要使用 MinGW-std-threads 庫,您需要將宏 _WIN32_WINNT 定義為 0x0501 (Windows XP) 或更高版本。
#error 要使用 MinGW-std-threads 庫,您需要將宏 _WIN32_WINNT 定義為 0x0501 (Windows XP) 或更高版本。
要使用此標題,請按照說明進行操作。
mingw.thread.h
標頭並將其保存在包含路徑中的某個位置。#include <thread>
更改為#include "mingw.thread.h"
_WIN32_WINNT
。 最簡單的方法是通過 gcc 命令行,例如添加-D_WIN32_WINNT=0x0501
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.