Okay, so I've compiled a simple logger I wrote into a library so I can include it with other projects. But when I try to include the header for that logger, it fails compilation.
Here is my Makefile linking the library:
CC= clang++
PROG= ./bin/tetris
OBJS= ./src/main.o ./src/Tetris.o ./src/states/BaseState.o ./src/states/MenuState.o \
./src/states/GameState.o
LIBS= allegro-5.0 allegro_dialog-5.0 allegro_font-5.0 allegro_ttf-5.0 allegro_color-5.0
CXXFLAGS= -g -Wall -std=c++11
LDFLAGS= $(shell pkg-config --static --libs ${LIBS}) -I./src/util -L./src/util/ -lsimplog
all: $(PROG)
$(PROG): $(OBJS)
mkdir -p ./bin/
$(CC) -o $(PROG) $(CXXFLAGS) $(OBJS) $(LDFLAGS)
rm -f $(OBJS)
clean:
rm -f $(PROG) $(TEST_PROG) $(OBJS)
The library is libsimplog.a
and is located in the src
directory of this project. I'm compiling it in a separate project folder, then copying here. simplog.h/simplog.c only exist in the project folder where I'm initially compiling this library. From what I understand, -L ./src/ -lsimplog
in my compile flags should be linking this library. However, my #include "simplog.h"
is still failing upon compilation:
fatal error: simplog.h: No such file or directory
I'm compiling the library in its own project folder, separate from this project. simplog.h/simplog.c exist in that project, not this one. The makefile for the other project that compiles this library is as follows:
CC = clang
CFLAGS = -Wall -c
LIB = libsimplog.a
SOURCE = simplog.c
OBJ = simplog.o
all:
$(CC) $(CFLAGS) $(SOURCE)
ar -cvq $(LIB) $(OBJ)
clean:
rm -f $(LIB)