我的makefile如下: EXECUTABLE := run_exe LIB_TAG := ../lib/libsgip.a LIBS := pthread INSTALL := mv $(LIB_TAG) ../lib# Now alter any implicit rules' variables if you like, e.g.: # # 现在来改变任何你想改动的隐含规则中的变量,例如 CFLAGS := -g -Wall -O3 -I../include CXXFLAGS := $(CFLAGS) # The next bit checks to see whether rm is in your djgpp bin # directory; if not it uses del instead, but this can cause (harmless) # `File not found' error messages. If you are not using DOS at all, # set the variable to something which will unquestioningly remove # files. # # 下面先检查你的 djgpp 命令目录下有没有 rm 命令,如果没有,我们使用 # del 命令来代替,但有可能给我们 'File not found' 这个错误信息,这没 # 什么大碍。如果你不是用 DOS ,把它设定成一个删文件而不废话的命令。 RM:= rm -f # You shouldn't need to change anything below this point. # # 从这里开始,你应该不需要改动任何东西。(我是不太相信,太NB了!) CC := g++ SOURCE := $(wildcard *.c) $(wildcard *.cc) OBJS := $(patsubst %.c,%.o,$(patsubst %.cc,%.o,$(SOURCE))) DEPS := $(patsubst %.o,%.d,$(OBJS)) MISSING_DEPS := $(filter-out $(wildcard $(DEPS)),$(DEPS)) MISSING_DEPS_SOURCES := $(wildcard $(patsubst %.d,%.c,$(MISSING_DEPS)) \ $(patsubst %.d,%.cc,$(MISSING_DEPS))) CPPFLAGS += -MD .PHONY : everything deps objs clean veryclean rebuild everything : $(EXECUTABLE) deps : $(DEPS) objs : $(OBJS) libs : $(OBJS) ar cru $(LIB_TAG) $(OBJS) install : @$(INSTALL) clean : @$(RM) *.o @$(RM) *.d @$(RM) $(LIB_TAG) veryclean: clean @$(RM) $(EXECUTABLE) rebuild: veryclean everything ifneq ($(MISSING_DEPS),) $(MISSING_DEPS) : @$(RM) $(patsubst %.d,%.o,$@) endif -include $(DEPS) $(EXECUTABLE) : $(OBJS) g++ -o $(EXECUTABLE) $(OBJS) $(addprefix -l,$(LIBS)) 当我在linux7.3中间执行make的时候,出现错误提示如下: /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../crt1.o: In function `_start': /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../crt1.o(.text+0x18): undefined r eference to `main' collect2: ld returned 1 exit status 您能告诉原因吗?谢谢您,我真的很着急 |