- 论坛徽章:
- 0
|
一个简单的C程序test.c:
#include <stdio.h>
int main ()
{
int i;
FILE *fp;
fp = fopen("./a.txt","a");
fprintf(fp,"hello");
fflush(fp);
fclose(fp);
}
用命令 cc -o test test.c编译时报错
/tmp/ccwgM9Tm.o(.text+0x1f): In function `main':
: undefined reference to `__fopen'
collect2: ld returned 1 exit status
头文件stdio.h是/usr/lib/bcc/include/下拷到/usr/include下的
(拷贝的原因是在系统上装了oracle9.2.0.4客户端后编译pc程序时报stdio.h内很多include文件没有,于是按照BBS上一建议拷贝,拷后当时编译不在出错)
用grep fopen stdio.h查看有
* in stdio_init and fopen */
extern FILE *__fopen __P((char*, int, FILE*, char*));
#define fopen(__file, __mode) __fopen((__file), -1, (FILE*)0, (__mode))
#define freopen(__file, __mode, __fp) __fopen((__file), -1, (__fp), (__mode))
#define fdopen(__file, __mode) __fopen((char*)0, (__file), (FILE*)0, (__mode))
现求‘fopen’问题的解决方法。
另哪位大大能否提供一下redhat linux 下proc 和cc 的编译环境配置,不胜感激! |
|