C++ mutex in namespace std does not name a type

前端 未结 11 935
日久生厌
日久生厌 2020-11-28 13:22

I\'m writing a simple C++ program to demonstrate the use of locks. I am using codeblocks and gnu gcc compiler.

 #inclu         


        
11条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-28 13:44

    I encountered this same problem when using MingW-W64 7.2.0. I tested out several different Windows builds from the mingw-64 download page, and found that MinGW-W64 GCC-8.1.0 supports mutex and contains the pthread library. When installing, I selected the following options:

    • x86_64
    • posix
    • seh

    My multi-threaded code based on pthreads now compiles and runs cleanly on both Windows and Linux with no changes.

    This version is leaner than the 7.3.0 build I was using because it doesn't have a CygWin environment or package manager. I also copied mingw32-make.exe to make.exe so my Makefile wouldn't need to be modified. The installer creates a "Run terminal" link in the Windows Start Menu.

提交回复
热议问题