gcc -pthread_错误-在GCC Linux中使用C程序未定义对'pthread_create'的引用
gcc -pthread
在Linux中修复对'pthread_create'的未定义引用 (Fixing undefined reference to 'pthread_create' in Linux)
This is a common error while compiling C program in GCC/G++ Linux. This error occurs when you are using pthread_create function to create threads in your programs.
这是在GCC / G ++ Linux中编译C程序时的常见错误。 当您使用pthread_create函数在程序中创建线程时,会发生此错误。
要解决此问题,请确保以下几点: (To fix this problem ensure following points:)
Include header file pthread.h in your program.
在程序中包含头文件pthread.h 。
Add –lpthread linker flag with compilation command.
在编译命令中添加–lpthread链接器标志。
1-包括头文件 (1- Include Header file)
#include <stdio.h>#include <pthread.h>......2-编译命令 (2- Compile command)
gcc main.c -o main -lpthreadTo more explanation : C program with pthread.h library in Linux.
要更多说明: Linux中带有pthread.h库的C程序。
翻译自: https://www.includehelp.com/c-programming-questions/error-undefined-reference-to-pthread-create-in-linux.aspx
gcc -pthread
创作挑战赛新人创作奖励来咯,坚持创作打卡瓜分现金大奖总结
以上是生活随笔为你收集整理的gcc -pthread_错误-在GCC Linux中使用C程序未定义对'pthread_create'的引用的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: [转载] python学习笔记
- 下一篇: 在Linux中制作实用程序(MakeFi