简体   繁体   English

mingw.thread.h头文件安装不当

[英]Improper mingw.thread.h header file installation

I originally asked a question regarding issues I am having getting the #include header file to function correctly.我最初问了一个关于我让 #include 头文件正常运行的问题的问题。 C++ multithreading errors . C++ 多线程错误 Specifically, I get the error that "'thread' was not declared in this scope".具体来说,我收到“'thread' 未在此范围内声明”的错误。 I am beginning to wonder if my original assumption that I was installing the mingw.thread.h header file incorrectly (located here: https://github.com/meganz/mingw-std-threads ).我开始怀疑我最初的假设是否错误地安装了 mingw.thread.h 头文件(位于此处: https : //github.com/meganz/mingw-std-threads )。 This seemingly helps solve these issues for many people,这似乎有助于解决很多人的这些问题,

Can someone provide a description of how to install this file correctly?有人可以提供有关如何正确安装此文件的说明吗?

These are the results when I run gcc -v on my terminal:这些是我在终端上运行 gcc -v 时的结果:

Using built-in specs.使用内置规范。

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)

edit: To help, when I include the "mingw.thread.h" and compile, I get these errors:编辑:为了提供帮助,当我包含“mingw.thread.h”并编译时,出现以下错误:

error: #error To use the MinGW-std-threads library, you will need to define the macro _WIN32_WINNT to be 0x0501 (Windows XP) or higher.错误:#error 要使用 MinGW-std-threads 库,您需要将宏 _WIN32_WINNT 定义为 0x0501 (Windows XP) 或更高版本。

#error To use the MinGW-std-threads library, you will need to define the macro _WIN32_WINNT to be 0x0501 (Windows XP) or higher. #error 要使用 MinGW-std-threads 库,您需要将宏 _WIN32_WINNT 定义为 0x0501 (Windows XP) 或更高版本。

To use this header follow the instructions .要使用此标题,请按照说明进行操作

  1. Download the mingw.thread.h header and save it somewhere on your include path.下载mingw.thread.h标头并将其保存在包含路径中的某个位置。
  2. Change #include <thread> to #include "mingw.thread.h" in your code将代码中的#include <thread>更改为#include "mingw.thread.h"
  3. If you aren't already you need to make sure that you define _WIN32_WINNT correctly.如果您还没有,您需要确保正确定义_WIN32_WINNT The easiest way to do this is via the gcc command line, eg add -D_WIN32_WINNT=0x0501 .最简单的方法是通过 gcc 命令行,例如添加-D_WIN32_WINNT=0x0501

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM