首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

关于makefile编写的有关问题

2012-03-01 
关于makefile编写的问题如何编写含有外部变量的makefile。我的写法如下:main.c--#include print.h #inclu

关于makefile编写的问题
如何编写含有外部变量的makefile。我的写法如下:

main.c--

#include "print.h "
#include "define.txt "
main()
{print();}

define.txt--

int   a=1;

extern.txt--

extern   int   a;

print.h--

void   print(void);

print.c--
#include <stdio.h>
#include "extern.txt "
void   print(void)
{   printf( "5a=%d\n ",5*a);}

错误提示如下   :
[root@localhost   try]#   make
cc         -c   -o   print.o   print.c
gcc   -o   main   print.o
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../crt1.o:   In   function   `_start ':
(.text+0x18):   undefined   reference   to   `main '
print.o:   In   function   `print ':
print.c:(.text+0x7):   undefined   reference   to   `a '
collect2:   ld   返回   1
make:   ***   [main]   错误   1


[解决办法]
你的define.txt应该改为define.c, 因为那句是定义.

热点排行