linux_thread_learn

来源:互联网 发布:手机淘宝首页红包 编辑:程序博客网 时间:2024/04/26 06:15
由于是Linux新手,学习多线程时候,编写的第一个线程 程序出现
undefined reference to 'pthread_create'
问题原因:
    pthread 库不是 Linux 系统默认的库,连接时需要使用库libpthread.so,所以在使用pthread_create()创建线程。需要链接该库。

    在编译中要加 -lpthread参数
gcc -g -o my_thread_create my_thread_create.c -lpthread

原创粉丝点击