+ -
当前位置:首页 → 问答吧 → ubuntu 10 安装 codebloscks 10 以及汉化补丁

ubuntu 10 安装 codebloscks 10 以及汉化补丁

时间:2010-10-15

来源:互联网

随便写的小程序,始终无法编译通过
#include <stdio.h>
#include <pthread.h>

void* threadtest(void* param)
{
int* np = (int*)param;

printf("thread test %d\r\n", *np);

return 0;
}

int main(int argc, char* argv[])
{
unsigned long int pid = 0;
int np = 123;
pthread_create(&pid, 0, threadtest, &np);

pthread_join(pid, 0);

return 0;
}

ls /usr/lib/libpthread*
/usr/lib/libpthread.a /usr/lib/libpthread_nonshared.a /usr/lib/libpthread.so

gcc test.c -llibpthread.a (无法找到库文件)
/usr/bin/ld: cannot find -llibpthread.a
collect2: ld returned 1 exit status

gcc test.c -llibpthread.so (无法找到库文件)
/usr/bin/ld: cannot find -llibpthread.so
collect2: ld returned 1 exit status

gcc test.c -l/usr/lib/libpthread.a (无法找到库文件)
/usr/bin/ld: cannot find -l/usr/lib/libpthread.a
collect2: ld returned 1 exit status

作者: xtchina   发布时间: 2010-10-15

void* threadtest(void* param) 是外部函数 的要加 extern

作者: arvin1025   发布时间: 2010-10-15

arvin1025 写道:
void* threadtest(void* param) 是外部函数 的要加 extern


gcc找不到库文件,好像跟语法没有关系吧?

作者: xtchina   发布时间: 2010-10-15