如何在 Minix 中使用 <minix/mthread.h> 进行编译?

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

目前正在研究Minix,正在做基于threads的系统,不知道如何编译自己的程序

例如: 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);
}

然后我运行编译:

# 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)

知道如何进行这项工作吗?

编译时使用mthread库。试试吧,你会解决你的问题

clang Mthreads.c -lmthread