i'm using gcrypt, compiler seems unable find it. here makefile. function.c function source file containing functions defined; wrote header file miao.h function declaration, , gcrypt.h included in it. main.c source file including miao.h. when make: .could me? bothers me long.
cc = gcc cflags = 'libgcrypt-config --cflags' libs = 'libgcrypt-config --libs' objs = function.o main.o main all: $(objs) function.o: function.c $(cc) -c function.c $(cflags) main.o: main.c $(cc) -c main.c $(cflags) main: main.o function.o $(cc) -o main main.o function.o $(libs) clean: rm $(objs)
the makefile should written more following:
caveat: unable test makefile not have libgcrypt-config available.
per web site: https://gnupg.org/documentation/manuals/gcrypt/building-sources.html
libgcrypt-config
executable should surrounded back-ticks, not single quotes executed in current shell.
(back ticks on stackoverflow result in emphasised text should still visible should placed.)
note: have placed <tab>
actual makefile needs have tab character
note: targets, all
, clean
not produce file same name, in file there needs statement: .phony: clean
when defining macro, use :=
rather =
macro evaluated once.
any calls shell functions should incorporated via macro, easy make change. in general best include path shell function: wrote on linux, path may different. specifying actual path becomes important when cross compiling or there duplicate names visible via $path statement (as can case gcc
)
note: actual libgcrypt-config
executable must in visible via $path environment variable.
note: individual compile statements reduced following 2 lines: (and nothing else needed compiles)
%.o: %.c <tab>$(cc) -c $< -o $@ -i. $(cflags)
note: not place contents of rule dependencies
expected. error noted in clean:
target
the proposed makefile follows:
cc := /usr/bin/gcc rm := /usr/bin/rm cflags := `libgcrypt-config --cflags` libs := `libgcrypt-config --libs` objs := function.o main.o main target := main .phony: clean all: $(target) function.o: function.c <tab>$(cc) -c function.c $(cflags) -o function.o -i. main.o: main.c <tab>$(cc) -c main.c $(cflags) -o main.o -i. $(target): $(objs) <tab>$(cc) -o $(target) $(objs) $(libs) clean: <tab>$(rm) -f $(objs)
Comments
Post a Comment