c - Makefile: multiple defintion of '_start' -
i've searched around answer, none of i've seen problems own makefile has.
eos$ make gcc objects.o -o bumper_cars objects.o: in function `_start': (.text+0x0): multiple definition of `_start' /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crt1.o:(.text+0x0): first defined here objects.o: in function `_fini': (.fini+0x0): multiple definition of `_fini' /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crti.o:(.fini+0x0): first defined here objects.o:(.rodata+0x0): multiple definition of `_io_stdin_used' /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crt1.o:(.rodata.cst4+0x0): first defined here objects.o: in function `__data_start': (.data+0x0): multiple definition of `__data_start' /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crt1.o:(.data+0x0): first defined here objects.o:(.rodata+0x8): multiple definition of `__dso_handle' /usr/lib/gcc/x86_64-redhat-linux/4.4.7/crtbegin.o:(.rodata+0x0): first defined here objects.o: in function `_init': (.init+0x0): multiple definition of `_init' /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crti.o:(.init+0x0): first defined here /usr/lib/gcc/x86_64-redhat-linux/4.4.7/crtend.o:(.dtors+0x0): multiple definition of `__dtor_end__' objects.o:(.dtors+0x8): first defined here /usr/bin/ld: warning: cannot create .eh_frame_hdr section, --eh-frame-hdr ignored. /usr/bin/ld: error in objects.o(.eh_frame); no .eh_frame_hdr table created. collect2: ld returned 1 exit status and makefile:
cc = gcc cflags = -wall -std=c99 -g -pthread all: objects.o bumper_cars objects.o: bumper_cars.c sleeper.c sleeper.h $(cc) $(cflags) $^ -o $@ -c bumper_cars: objects.o $(cc) $^ -o $@ clean: rm -f bumper_cars.o rm -f bumper_cars
here link may want know make utility: http://www.gnu.org/software/make/manual/make.html.
the posted make file has few oops. 1 of oops several *.c files not make single .o file rather several .o files.
library files used in link step header files used in compile step in following, compiler warnings enabled.
i suggest using this:
cc := gcc cflags := -wall -wextra -pedantic -std=c99 -g libs := -lpthread rm := rm -f .phony: clean name := bumper_cars srcs := $(wildcard *.c) objs := $(srcs:.c=.o) all: $(objs) $(name) # # link .o files target executable # $(name): $(objs) $(cc) $^ -o $@ $(libs) # # compile .c file .o files using compiler flags # %.o: %.c sleeper.h $(cc) $(cflags) -c $< -o $@ -i. clean: $(rm) *.o $(rm) bumper_cars
Comments
Post a Comment