2017-01-05 17 views
1
std::this_thread::sleep_for(std::chrono::milliseconds(1000)); 

clang++ main.cpp -o main.exe -g -std=c++1z --target=x86_64-w64-mingw32C++のstd :: this_thread :: sleep_forコンパイラエラー(打ち鳴らす)でコンパイル

私は、このエラーを与える:

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) 

起こっていただきましたか?

+4

私は、動作するには '-lpthread'を追加する必要があると思います。 – SergeyA

+4

これは_linker_エラーであり、コンパイラエラーではありません。 – ildjarn

+0

ありがとう、それは '-pthread'で解決しました 私はこのコンパイラオプションを使う前に覚えていません... – Patric

答えて

0

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

関連する問題