当前位置: 技术问答>linux和unix
一个很简单的问题?(急,急,急)
来源: 互联网 发布时间:2015-09-24
本文导语: 我用Kdevelop编写一个简单的线程程序,编译通通过,但是连接出错,提示如下错误: No rule to make target `pthread', needed by `threadtest'. Stop. threadtest是我的项目名, 代码 如下: #include #include #include #include #include void...
我用Kdevelop编写一个简单的线程程序,编译通通过,但是连接出错,提示如下错误:
No rule to make target `pthread', needed by `threadtest'. Stop.
threadtest是我的项目名, 代码 如下:
#include
#include
#include
#include
#include
void printthread(void *arg)
{
char *str=new char[10];
strcpy(str, (char *)arg);
printf("%sn", str); // No rule to make target `pthread', needed by `threadtest'. Stop.
}
int main()
{
pthread_t *thread;
if( (thread=(pthread_t *)malloc(sizeof(pthread_t) ) ) == NULL)
{
perror("alloc for client thread error!");
exit(1);
}
char str[40];
strcpy(str, "hello world!");
if( pthread_create( thread, NULL, printthread, (void *)str) !=0 )
{
printf("Create Thread Error:n");
exit(1);
}
}
这是什么原因,急盼各位大哥帮忙解决一下,不胜感激!!
No rule to make target `pthread', needed by `threadtest'. Stop.
threadtest是我的项目名, 代码 如下:
#include
#include
#include
#include
#include
void printthread(void *arg)
{
char *str=new char[10];
strcpy(str, (char *)arg);
printf("%sn", str); // No rule to make target `pthread', needed by `threadtest'. Stop.
}
int main()
{
pthread_t *thread;
if( (thread=(pthread_t *)malloc(sizeof(pthread_t) ) ) == NULL)
{
perror("alloc for client thread error!");
exit(1);
}
char str[40];
strcpy(str, "hello world!");
if( pthread_create( thread, NULL, printthread, (void *)str) !=0 )
{
printf("Create Thread Error:n");
exit(1);
}
}
这是什么原因,急盼各位大哥帮忙解决一下,不胜感激!!
|
加上 pthread库
gcc -othreadtest *.c -lpthread
gcc -othreadtest *.c -lpthread
|
??
你是用什么make的?
直接gcc threadtest.c -lpthread
还是有个makefile?
你的makefile写的对吗?
你是用什么make的?
直接gcc threadtest.c -lpthread
还是有个makefile?
你的makefile写的对吗?
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。