Context first: I have a header (event.h), a program called event.c, and the main program main.c. This program will be compiled, generating first a object program (event.o), then a static library (libevent.a) in a separate folder, and then the executable program work1.exe
To do this I created this makefile:
work1 : main.c libevent.a gcc -static main.c -L./lib -levent -o work1 -Wall event.o: event.c gcc -c event.c -Wall libevent.a: event.o ar rcs lib/libevento.a event.o clean: rm work1 *.o The result of executing the makefile leads to this error:
$ make gcc -c event.c -Wall ar rcs lib/libevent.a event.o gcc -static main.c -L./lib -levent -o work1 -Wall /usr/bin/ld: cannot find -lc collect2: ld returned 1 exit status make: *** [work1] Error 1 Any idea what is going on here? Is there a way to compiling this without installing anything?
ar rcs lib/libevento.a event.o<- typo here or in the actual makefile?yum install glibc-static. If that doesn't work, yourLIBRARY_PATHmore than likely does not include the location oflibc.a(although I would assume-L./libwould have that...)gcc main.c -L./lib -l event -o work -Wall