在 eclipse (Fedora) 上的 c 程序中对 pthread_create 的未定义引用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4334206/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 15:25:53  来源:igfitidea点击:

undefined reference to pthread_create in c program on eclipse (Fedora)

ceclipsefedora

提问by Lokesh

I have a problem in building a c thread program. Program is giving error like "undefined reference to pthread_creat". I searched and found to use gcc options like "gcc -lpthread -o ...."

我在构建 ac 线程程序时遇到问题。程序给出了“未定义对 pthread_creat 的引用”之类的错误。我搜索并发现使用 gcc 选项,如“gcc -lpthread -o ....”

But I not able to set it for eclipse. I tried to make change in makefile but every time it got replaced with default options. Please help me to set these gcc options and write about where and how to set gcc options in eclipse on fedora 10.

但我无法为日食设置它。我试图在 makefile 中进行更改,但每次都被默认选项替换。请帮助我设置这些 gcc 选项,并写下在 Fedora 10 上的 eclipse 中在哪里以及如何设置 gcc 选项。

Thanks,

谢谢,

Lokesh

洛克什

回答by M.ElSaka

to add pthread library to your project flow these steps (in eclipse):

要将 pthread 库添加到您的项目流程中,请执行以下步骤(在 eclipse 中):

right cklick on the project in the project explorer -> properties -> c/c++ build -> Settings -> linker -> libraries -> add -> pthread -> ok -> rebuild

在项目资源管理器中右键单击项目 -> 属性 -> c/c++ 构建 -> 设置 -> 链接器 -> 库 -> 添加 -> pthread -> 确定 -> 重建

回答by Klark

Check this'tutorial' on about how to setup eclipse for developing posix threads.

检查“教程”关于如何设置的Eclipse开发POSIX线程。

Hope it helps.

希望能帮助到你。

回答by Tushar R.

To add pthread library to your non-makefile project, do following steps (in eclipse):

要将 pthread 库添加到非 makefile 项目,请执行以下步骤(在 eclipse 中):

right click on the project in the project explorer. Select properties -> c/c++ general -> Paths and Symbols -> libraries -> add -> type 'pthread' in text box -> ok -> ok -> rebuild

右键单击项目资源管理器中的项目。选择属性 -> c/c++ 常规 -> 路径和符号 -> 库 -> 添加 -> 在文本框中键入“pthread” -> 确定 -> 确定 -> 重建