c++ std::this_thread::sleep_for compiler error (clang)

1.9k Views Asked by At
std::this_thread::sleep_for(std::chrono::milliseconds(1000));

Compiled with : clang++ main.cpp -o main.exe -g -std=c++1z --target=x86_64-w64-mingw32

Give me this error:

C:\Users\this_\AppData\Local\Temp\main-124cc2.o: In function `void std::this_thread::sleep_for<long long, std::ratio<1ll, 1000ll> >(std::chrono::duration<long long, std::ratio<1ll, 1000ll> > const&)':
C:\mingw-w64\mingw64\lib\gcc\x86_64-w64-mingw32\6.2.0\include\c++/thread:322: undefined reference to `nanosleep'
clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation)

Whats happening?

1

There are 1 best solutions below

0
On

using std::this_thread::sleep_for(std::chrono::milliseconds(1000))‌​; instead.