Reputation: 1
I'm editing an example file already in a library. Inside the directory of the example, there is a Makefile that I have been using to compile and run the example. I now want to add an additional library to this make file, I have tried copy and pasting the header and .c file into the library folder specified in the Makefile, but it is not finding it. Here is the Makefile code:
CPPFLAGS = -I../../include
CFLAGS =
LDFLAGS = -L../../lib -L../../lib64
LIBS = -lbsapi
Biometry: main.c
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) main.c -o Biometry $(LIBS)
The library that I wanted to add came with a .h file and a .c file. I have added those to the ../../include directory and made sure to add this to my code right below the previous #include
#include <tpl.h>
I am not sure what I am missing? The program ran properly before the addition of this library.
Upvotes: 0
Views: 16803
Reputation: 36317
Libraries are usually first built and installed to your system, so you can later add them to what seems to be LIBS
in your Makefile (let's say your library's called "foo", -lfoo
).
So you've got two options:
LIBS= -lbsapi -lfoo
, orBiometry
needs, and add a recipe on how to build foo.o
from foo.c
, and add foo.c
to your sources:CPPFLAGS = -I../../include CFLAGS = LDFLAGS = -L../../lib -L../../lib64 LIBS = -lbsapi Biometry: main.c foo.o $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) main.c foo.o -o Biometry $(LIBS) foo.o: foo.c $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) foo.c -o foo.o $(LIBS)
Upvotes: 2