Search code examples
macosmakefilearchive

make not working as expected


Hey guys I wrote a makefile which work perfectly fine on my 27" iMac at home running Snow Leopard, however when I uploaded it to my uni's computer, a 24" running Snow Leopard as well, it gets the following:

gcc -std=c99 -Wall -pedantic -Werror -c print.c
gcc -std=c99 -Wall -pedantic -Werror -c process.c
gcc -std=c99 -Wall -pedantic -Werror -c sync.c
gcc -std=c99 -Wall -pedantic -Werror -c option_a.c
gcc -std=c99 -Wall -pedantic -Werror -c option_m.c
gcc -std=c99 -Wall -pedantic -Werror -c option_n.c
gcc -std=c99 -Wall -pedantic -Werror -c option_p.c
gcc -std=c99 -Wall -pedantic -Werror -c option_r.c
gcc -std=c99 -Wall -pedantic -Werror -c option_u.c
gcc -std=c99 -Wall -pedantic -Werror -c option_v.c
ar -rc libopt.a option_a.o option_m.o option_n.o option_p.o option_r.o option_u.o option_v.o
gcc -std=c99 -Wall -pedantic -Werror -o mysync mysync.c print.o process.o sync.o libproj2.a libopt.a
libproj2.a: could not read symbols: Archive has no index; run ranlib to add one
collect2: ld returned 1 exit status
make: *** [mysync] Error 1

The following is my makefile:

PROJECT = mysync
COMPILE = gcc -std=c99 -Wall -pedantic -Werror
OPT_OBJ = option_a.o option_m.o option_n.o option_p.o option_r.o option_u.o option_v.o
MAIN = print.o process.o sync.o

$(PROJECT): $(PROJECT).c $(MAIN) libproj2.a libopt.a
    $(COMPILE) -o mysync $(PROJECT).c $(MAIN) libproj2.a libopt.a

libopt.a: $(OPT_OBJ)
    ar -rc libopt.a $(OPT_OBJ)

%.o: %.c $(PROJECT).h
    $(COMPILE) -c $<

clean:
    rm -f *.o libopt.a

Solution

  • The problem lies with the provided libproj2.a. Contact library provider for support.