簡體   English   中英

Eclipse:無法識別的選項“ -pthread”

[英]Eclipse: unrecognized option '-pthread'

我是C語言中的新編程人員,現在我正嘗試在正在開發的電機控制程序中實現線程,但是我的問題是我無法在eclipse中運行pthread.h庫。 盡管已經為Win32安裝了POSIX線程庫

信息:內部生成器用於生成

gcc -O3 -g3 -Wall -pthread -c -fmessage-length=0 -o src\main.o ..\src\main.c 
gcc: error: unrecognized option '-pthread'
Info: Parallel threads used: 1

即使我只說圖書館

#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>

int main(void) {
    return EXIT_SUCCESS;
}

在此處輸入圖片說明

檢查論壇幾次,他們是否想在-pthread雜項中建立並鏈接phtread,但我無法解決問題,有人可以幫助我嗎?

我有Windows 10(64位)。

如果您的代碼未編譯 ,則需要在gcc編譯中添加-pthread參數,如下所示。

  1. 導航到:項目->屬性
  2. 左側: c / c ++構建-> GCC C編譯器->其他
  3. Other Flags部分的開頭添加-pthread參數
  4. 另外pthread庫添加c / c ++ build->設置-> GCC C Linker->庫
  5. 並將pthread庫包含到其他庫中。
  6. 單擊應用。
  7. 清理並構建項目。

如果僅您只有一個未解決的包含問題,那么請為pthread.h指定文件系統路徑,因為編譯器不知道這一點。 在這里檢查如何在文件系統中添加pthread.h

我放棄了嘗試,轉而使用我使用的計數器卡(KL25Z)和事件編程。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM