cpthreadsclangminix

How compile with <minix/mthread.h> in Minix?


Currently, I am studying Minix and I am doing a system based on threads and do not know how to compile my program.

For example: Mthreads.c

#include <stdlib.h>
#include <stdio.h>
#include <minix/mthread.h>

void hola(int y){
     printf("Hola Mundo");
}

int main(){

    mthread_thread_t a;

    mthread_create(&a, NULL, (void*)hola, 0);
    mthread_join(a, NULL);
}

Then I run clang to compile:

# clang Mthreads.c 
/var/tmp/g-10649b.o: In function `main':
Mthreads.c:(.text+0x5f): undefined reference to `mthread_create'
Mthreads.c:(.text+0x7d): undefined reference to `mthread_join'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Any idea how to make this work?


Solution

  • Use mthread library when compiling. Try it and you will solve your problem

    clang Mthreads.c -lmthread