2

我想在 C++ 中使用 openFst 和 Thrax 库(都用于文本匹配和屏蔽) openfst 以及 MITIE 库github(使用它的标记化功能)。但是我无法为从所有三个库中导入头文件的代码创建 Makefile。像这样的东西:

#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>

我现在拥有的 Makefile 如下所示:

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

如何使用上述头文件成功编译此 Makefile?

4

0 回答 0