Such is the code:
#include <iostream> #include <unistd.h> #include <pthread.h> #include <sys/types.h> using namespace std; void* helloWorld(void *args) { cout << "Hello from thread!\n"; } int main() { pthread_t thread; pthread_create(&thread, NULL, helloWorld, NULL); return 0; } It produces errors:
undefined reference to `pthread_create '
collect2: error: ld returned 1 exit status
I do not understand the reason for their appearance.
libpthreadlibrary. - PinkTux-pthreadto the compilation keys -g++ -pthread t.cpp- avp