|
这个程序是制顶帖中的那个演示怎么使用make的程序。
写好后,我可以用
gcc -o main.c func1.c func2.c编译成功,但是我要是分开编译就不行了
[bisong@localhost progtest]$ gcc -c main.c
[bisong@localhost progtest]$ gcc -c func1.c
[bisong@localhost progtest]$ gcc -c func2.c
[bisong@localhost progtest]$ gcc -o main.o func1.o func2.o
/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../../crt1.o(.text+0x18): In function `_start':../sysdeps/i386/elf/start.S:77: undefined reference to `main'
collect2: ld returned 1 exit status
不知道这是为什么
我按照那个置顶帖上的Makefile抄了一下,但是在我make的时候出现下面的错误
[bisong@localhost progtest]$ make
Makefile:2: *** missing separator. Stop.
这个是什么意思阿?
小弟刚接触linux的编成,望各位大哥大姐多多帮助。
#include<stdio.h>
#include "mytool1.h"
#include "mytool2.h"
int main()
{
printf("Now In main function\n");
func1("Now In func1\n");
func2("Now In func2\n");
return 0;
}
[bisong@localhost progtest]$ cat func1.c
#include "mytool1.h"
void func1(char *print_str)
{
printf("This is func1 print %s\n", print_str);
}
[bisong@localhost progtest]$ cat func2.c
#include "mytool2.h"
void func2(char *print_str)
{
printf("This is func2 print %s\n",print_str);
}
[bisong@localhost progtest]$ cat mytool1.h
#ifndef _MYTOOL_1_H
#define _MYTOOL_1_H
void func1(char *print_str);
#endif
[bisong@localhost progtest]$ cat mytool2.h
#ifndef _MYTOOL_2_H
#define _MYTOOL_2_H
void func2(char *print_str);
#endif |
|