0

When I am trying to compile or include the relevant header file for std::mutex, it cannot be found. I suspect the issue is related to my CMake but as I am new to it, I am not sure what is missing.

This is my CMake file:

cmake_minimum_required(VERSION 3.8)
project(display)
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")
set(CMAKE_CXX_STANDARD 17)

set(SOURCE_FILES main.cpp Display.cpp Display.h Utilities.cpp Utilities.h)
add_executable(display ${SOURCE_FILES})

set(MY_TEST_SOURCES Display_test.cpp Utilities.cpp Display.cpp)
add_executable(display_test ${MY_TEST_SOURCES})

enter image description here

halfer
  • 19,824
  • 17
  • 99
  • 186
user3270371
  • 105
  • 10
  • Not so long ago, the standard MinGW did not support thread or mutexes. – Holt Aug 08 '17 at 18:15
  • 1
    Is this it? https://stackoverflow.com/questions/17551722/getting-stdthread-mutex-to-work-under-win7-with-mingw-and-g-4-7-2 – KABoissonneault Aug 08 '17 at 18:16
  • @KABoissonneault, I will give it a try and let you know in a moment. Thank you. – user3270371 Aug 08 '17 at 18:20
  • This is what I am using: http://mingw-w64.yaxm.org/doku.php According to their documentation, it should support that. – user3270371 Aug 08 '17 at 18:28
  • Search your hard drive. Is there a copy of a file called `mutex` on it? Examine your include paths. Is that header file in your include path? (Note: I'm not saying "blindly add such a header file to your include path", as it might be from a different compiler and horribly break your install if you try it, I'm just asking questions) – Yakk - Adam Nevraumont Aug 08 '17 at 18:32
  • Probably unrelated, but you haven't defined your CMake project to be C++. – usr1234567 Aug 08 '17 at 19:15
  • @usr1234567, I thought "set(CMAKE_CXX_STANDARD 17)" does that? Can you please point what is missing? – user3270371 Aug 08 '17 at 19:23
  • 2
    @user3270371 "By default C and CXX are enabled if no language options are given." – utopia Aug 08 '17 at 19:46

0 Answers0