当前位置: 技术问答>linux和unix
大家看看我的makefile哪里错了?
来源: 互联网 发布时间:2014-12-31
本文导语: LDADD= -ldisk -lcrypt CC= gcc OBJS= backup_restore.o commonfunctions.o restoreuse.o restorecgi.o cgic.o backup_restore: $(OBJS) $(CC) -o backup_restore $(OBJS) $(LDADD) backup_restore.o:backup_restore.c $(CC) -c backup_restore.c c...
LDADD= -ldisk -lcrypt
CC= gcc
OBJS= backup_restore.o commonfunctions.o restoreuse.o restorecgi.o cgic.o
backup_restore: $(OBJS)
$(CC) -o backup_restore $(OBJS) $(LDADD)
backup_restore.o:backup_restore.c
$(CC) -c backup_restore.c
commonfunctions.o: commonfunctions.c
$(CC) -c commonfunctions.c
restoreuse.o: restoreuse.c
$(CC) -c restoreuse.c
restorecgi.o: restorecgi.c
$(CC) -c restorecgi.c
cgic.o: cgic.c
$(CC) -c cgic.c
其中,每个.c文件只包括一个头文件,彼此之间没有关系,我运行make restore.mk后,屏幕出现:
bash-2.05# make -f restore.mk
gcc -o backup_restore backup_restore.o commonfunctions.o restoreuse.o restorecgi.o cgic.o -ldisk -lcrypt
commonfunctions.o(.data+0x0): multiple definition of `bootdisk'
backup_restore.o(.data+0x0): first defined here
commonfunctions.o(.data+0x140): multiple definition of `ACPkg_flag'
backup_restore.o(.data+0x140): first defined here
commonfunctions.o(.data+0x144): multiple definition of `ACPkg_flag0'
backup_restore.o(.data+0x144): first defined here
commonfunctions.o(.data+0x148): multiple definition of `ACPkg_flag1'
backup_restore.o(.data+0x148): first defined here
...
等信息,什么原因?
系统是freebsd.
CC= gcc
OBJS= backup_restore.o commonfunctions.o restoreuse.o restorecgi.o cgic.o
backup_restore: $(OBJS)
$(CC) -o backup_restore $(OBJS) $(LDADD)
backup_restore.o:backup_restore.c
$(CC) -c backup_restore.c
commonfunctions.o: commonfunctions.c
$(CC) -c commonfunctions.c
restoreuse.o: restoreuse.c
$(CC) -c restoreuse.c
restorecgi.o: restorecgi.c
$(CC) -c restorecgi.c
cgic.o: cgic.c
$(CC) -c cgic.c
其中,每个.c文件只包括一个头文件,彼此之间没有关系,我运行make restore.mk后,屏幕出现:
bash-2.05# make -f restore.mk
gcc -o backup_restore backup_restore.o commonfunctions.o restoreuse.o restorecgi.o cgic.o -ldisk -lcrypt
commonfunctions.o(.data+0x0): multiple definition of `bootdisk'
backup_restore.o(.data+0x0): first defined here
commonfunctions.o(.data+0x140): multiple definition of `ACPkg_flag'
backup_restore.o(.data+0x140): first defined here
commonfunctions.o(.data+0x144): multiple definition of `ACPkg_flag0'
backup_restore.o(.data+0x144): first defined here
commonfunctions.o(.data+0x148): multiple definition of `ACPkg_flag1'
backup_restore.o(.data+0x148): first defined here
...
等信息,什么原因?
系统是freebsd.
|
不会是你的.H
中间没有加
#ifndef XXXX_H
#define XXXX_H
...........
#endif
之类的把
中间没有加
#ifndef XXXX_H
#define XXXX_H
...........
#endif
之类的把
|
agree with upstair.
and check you program,some variables were dedined multiple times.
and check you program,some variables were dedined multiple times.
|
1)学习顶楼的说法
#ifndef __BACKUP_RESTORE_H__
#define __BACKUP_RESTORE_H__
#include "other.h"
#endif
2)把你的makefile改动一点
LDADD= -ldisk -lcrypt
CC= gcc
OBJS= backup_restore.o commonfunctions.o restoreuse.o restorecgi.o cgic.o
all:backup_restore
backup_restore: $(OBJS)
$(CC) $^ -o $@ $(LDADD) -O -Wall(for linux )
%.o:%.c
$(CC) &
#ifndef __BACKUP_RESTORE_H__
#define __BACKUP_RESTORE_H__
#include "other.h"
#endif
2)把你的makefile改动一点
LDADD= -ldisk -lcrypt
CC= gcc
OBJS= backup_restore.o commonfunctions.o restoreuse.o restorecgi.o cgic.o
all:backup_restore
backup_restore: $(OBJS)
$(CC) $^ -o $@ $(LDADD) -O -Wall(for linux )
%.o:%.c
$(CC) &