gcc求助
发表于 : 2008-02-01 14:27
我的gcc编译单个文件的时候没问题 但就是找不到自定义头文件里函数 几个文件是这样子的
test.c:
#include "print.h"
int main()
{
print("hello world\n!");
return 0;
}
print.h:
#ifndef _PRINT_H
#define _PRINT_H
void print(char *str1);
#endif
print.c:
#include "print.h"
#include <stdio.h>
void print(char *str1)
{
printf("%s",str1);
}
然后 gcc -o test test.c
提示是:
/tmp/cckKFlSB.o: In function `main':
test.c:(.text+0x19): undefined reference to `print'
collect2: ld 返回 1
不知道是不是gcc没配置好的缘故 请高位高手帮忙 谢了先
test.c:
#include "print.h"
int main()
{
print("hello world\n!");
return 0;
}
print.h:
#ifndef _PRINT_H
#define _PRINT_H
void print(char *str1);
#endif
print.c:
#include "print.h"
#include <stdio.h>
void print(char *str1)
{
printf("%s",str1);
}
然后 gcc -o test test.c
提示是:
/tmp/cckKFlSB.o: In function `main':
test.c:(.text+0x19): undefined reference to `print'
collect2: ld 返回 1
不知道是不是gcc没配置好的缘故 请高位高手帮忙 谢了先