2017-02-04 24 views
5

Mam pewne problemy podczas kompilowania programu z wielowątkowością ze standardowej biblioteki szablonów. powrót mi niejasne błąd, gdy próbuję skompilować następujący program:Problem z std :: thread z C++ 11

#include <iostream> 
#include <thread> 

void foo() 
{ 
    std::cout << "Thread 1\n"; 
} 

int main(int argc, char** argv) 
{ 
    std::thread tr(foo); 
    std::cout << "Main thread\n"; 
    tr.join(); 

    return 0; 
} 

Nie rozumiem błąd:

/tmp/ccE8EtL1.o : In the function « std::thread::thread<void (&)()>(void (&)()) » : 
file.cpp:(.text._ZNSt6threadC2IRFvvEJEEEOT_DpOT0_[_ZNSt6threadC5IRFvvEJEEEOT_DpOT0_]+0x21) : undefined reference to « pthread_create » 
    collect2: error : ld has return 1 execution status code 

skompilować go z:

g ++ -std = C++ 14 file.cpp -o test -Wall

Czy ktoś może pomóc mnie proszę ?

Odpowiedz

Powiązane problemy