I want to use the openFst and Thrax library (both used for text matching and masking) openfst along with MITIE library github (use its tokenization functionality) in C++. But I am unable to create a Makefile for the code where I import the header files from all three libraries. Something like this:
#include <fst/compat.h>
#include <thrax/compat/compat.h>
#include <thrax/compat/utils.h>
#include <fst/fst.h>
#include <fst/project.h>
#include <fst/rmepsilon.h>
#include <fst/shortest-path.h>
#include <fst/string.h>
#include <fst/symbol-table.h>
#include <fst/vector-fst.h>
#include <thrax/grm-manager.h>
#include <thrax/symbols.h>
#include <thrax/union.h>
#include <mitie/named_entity_extractor.h>
#include <mitie/conll_tokenizer.h>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstdlib>
The Makefile i have now looks like this:
SRC = tokenizer.cpp
TARGET = tokenizer
MITIEDIR = ../../../mitielib
FSTINCDIR=-I/usr/local/include
FSTLIBDIR=-L/usr/local/lib -L/usr/local/lib/fst -L/usr/local/lib/thrax
CFLAGS = -std=c++11 -Wstrict-prototypes -pedantic -Wall -W -I$(MITIEDIR)/include -I../../../dlib -I$(FSTINCDIR)
LDFLAGS = $(MITIEDIR)/libmitie.a $(FSTLIBDIR) -lpthread -lfst -ldl -lm -lrt -lfstfar -lthrax
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
#LDFLAGS += -static
endif
#ifeq ($(UNAME_S),Darwin)
# LDFLAGS +=
#endif
CC = gcc
####################################################
TMP = $(SRC:.cpp=.o)
OBJ = $(TMP:.c=.o)
$(TARGET): $(OBJ) $(MITIEDIR)
@echo Linking $@ with flags: $(LDFLAGS)
@$(CC) $(OBJ) -o $@ $(LDFLAGS)
@echo Build Complete
.PHONY: $(MITIEDIR)
$(MITIEDIR):
@$(MAKE) -C $(MITIEDIR)
.cpp.o: $<
@echo Compiling $<
@$(CC) -c $(CFLAGS) $< -o $@
.c.o: $<
@echo Compiling $<
@gcc -c $(CFLAGS) $< -o $@
clean:
@rm -f $(OBJ) $(TARGET)
@$(MAKE) -C $(MITIEDIR) clean
@echo All object files and binaries removed
dep:
@echo Running makedepend
@makedepend -- $(CFLAGS) -- $(SRC) 2> /dev/null
@echo Completed makedepend
How do I make this Makefile successfully compile using the above mentioned header files?