Не запускается поток

Пытаюсь запустить поток и в нем запустить mp3.

#include <thread>
#include <chrono>
#include <iostream>
#include <windows.h>
#pragma comment(lib, "winmm.lib")
 
void run() {
  mciSendString("play cl/resurse/voice/test.mp3 wait", NULL, 0, NULL)  ; 
}

int main() {
  std::thread th(run);
  std::cout << "end" << std::endl;
  return 0;
}

пытаюсь собрать g++ -c main.cpp

выдает ошибку

main.cpp: In function 'int main()':
main.cpp:14:21: error: no matching function for call to 'std::thread::thread(void (&)())'
   14 |   std::thread th(run);
      |                     ^
In file included from c:\users\redlava\gcc\include\c++\12.1.0\thread:43,
                 from main.cpp:1:
c:\users\redlava\gcc\include\c++\12.1.0\bits\std_thread.h:156:5: note: candidate: 'std::thread::thread(std::thread&&)'
  156 |     thread(thread&& __t) noexcept
      |     ^~~~~~
c:\users\redlava\gcc\include\c++\12.1.0\bits\std_thread.h:156:21: note:   no known conversion for argument 1 from 'void()' to 'std::thread&&'
  156 |     thread(thread&& __t) noexcept
      |            ~~~~~~~~~^~~
c:\users\redlava\gcc\include\c++\12.1.0\bits\std_thread.h:120:5: note: candidate: 'std::thread::thread()'
  120 |     thread() noexcept = default;
      |     ^~~~~~
c:\users\redlava\gcc\include\c++\12.1.0\bits\std_thread.h:120:5: note:   candidate expects 0 arguments, 1 provided

Возможно я среду неправильно настроил или еще что. P.s. Только начал учить плюсы, не судите строго.


Ответы (1 шт):

Автор решения: Bloody.cpp

Судя по всему у вас битый компилятор. Скорее всего вы просто скачали какой-то установщик с неизвестного сайта. Удалите ваш компилятор и сделайте всё как сказано здесь: Кляц. Не забудьте удалить старый путь к компилятору из Path и заменить его новым!

→ Ссылка