I'm writting a program with POSIX semaphore usage in CodeBlocks. So it can't compile even a such code :
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <semaphore.h>
int main()
{
sem_t a;
sem_init(&a, 0, 3);
return 0;
}
But using terminal and flag -lpthread
, everything works.
gcc main.c -lpthread
So, how can I add this flag to compiler?