简体   繁体   中英

How to link sqlite3 library with makefile

I'm trying to link sqlite3 to my project linked with a makefile. I read instructions to include slite3.c/.h files in my project but include an external library seems preferable to me.

The aim is to #include <sqlite3.h> instead of #include "sqlite3.h" . Is there a way to do this?

Here is my makefile:

CC=gcc
CFLAGS= -Wall -MMD -coverage
LDFLAGS= -lcmocka -coverage


all: main

main: connect_struct_UI.o UTest.o UTest_UI.o patient.o
     $(CC) $^ $(LDFLAGS) -o $@

%.o: %.c
     $(CC) -c $(CFLAGS) $< $^

run_test: main
     ./main ; \
     lcov --capture --directory . --output-file coverage.info ; \
     genhtml coverage.info --output-directory ../tests/coverage ; \
     valgrind ./$<

Thanks!

Solution was to add

LDFLAGS+= `pkg-config --libs sqlite3`

at the top of the Makefile

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM