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 #include ... ... 2-コンパイルコマンド(2-Compile command) gcc main.c -o main -lpthread To 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