2017-01-05 1 views
1

C++ 표준

std::this_thread::sleep_for(std::chrono::milliseconds(1000)); 
과 함께 컴파일 :: 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) 

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

나를이 오류를 준다?

+4

제 생각에는 작동하려면'-lpthread'를 추가해야한다고 생각합니다. – SergeyA

+4

이것은 컴파일러 오류가 아닌 _linker_ 오류입니다. – ildjarn

+0

감사합니다.'-pthread'로 해결했습니다. 이상하게도이 컴파일러 옵션을 사용하는 기억이 없습니다 ... – Patric

답변

0

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