Eclipse: unrecognized option '-pthread'

时间:2016-03-26 08:25:21

标签: c eclipse multithreading gcc pthreads

I'm new programming in C, now I'm trying to implement threads in a motor control program I am developing but my problem is that I can not run the pthread.h library in eclipse. despite haver installed POSIX threading library for Win32

Info: Internal Builder is used for build

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

Even though I'm just stating nothing but the library

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

int main(void) {
    return EXIT_SUCCESS;
}

enter image description here

多次查看论坛,并在-pthread杂项和链接phtread中做了他们想要建立的内容,但我无法解决问题,有人可以帮助我吗?

我有Windows 10,64位。

2 个答案:

答案 0 :(得分:0)

如果您的代码未编译,则需要在-pthread编译中添加gcc参数,如下所示。

  1. 导航至:项目 - &gt;特性
  2. 左侧: c / c ++ build - &gt; GCC C编译器 - &gt;其它
  3. -pthread开头添加Other Flags参数
  4. 也是pthread库添加c / c ++ build - &gt;设置 - &gt; GCC C Linker - &gt;库
  5. 并将pthread库包含在其他库中。
  6. 点击“应用”。
  7. 清理并构建项目。
  8. 如果您仅有未解决的包含问题,请指定pthread.h的文件系统路径,因为您的编译器不知道这一点。 Check here how to add pthread.h in your filesystem

答案 1 :(得分:0)

我放弃了尝试,使用我使用的计数卡(KL25Z)和事件编程。

相关问题