mirror of
https://github.com/yanyiwu/cppjieba.git
synced 2025-07-18 00:00:12 +08:00
rename src -> cppjieba && mv cppcommon out of compile in makefile and link it in using in demo
This commit is contained in:
parent
4ab7002a6f
commit
06d8b6f757
24
README.md
24
README.md
@ -92,8 +92,30 @@ Output:
|
|||||||
|
|
||||||
## Help
|
## Help
|
||||||
|
|
||||||
run `./segment_demo` to get help.
|
本项目主要是如下目录组成:
|
||||||
|
|
||||||
|
### cppcommon
|
||||||
|
|
||||||
|
主要是一些工具函数,例如字符串操作等。
|
||||||
|
make 之后产生一个libcm.a
|
||||||
|
要使用该libcm.a 只需要在代码里面增加
|
||||||
|
```cpp
|
||||||
|
#include "cppcommon/headers.h"
|
||||||
|
using namespace CPPCOMMON;
|
||||||
|
```
|
||||||
|
在链接时候`-Lcppcommon -lcm` 链接进即可。
|
||||||
|
__详细使用细节请参见demo/目录下的代码__
|
||||||
|
|
||||||
|
### cppjieba
|
||||||
|
核心目录,包含主要源代码。
|
||||||
|
make 之后产生libcppjieb.a
|
||||||
|
使用方法参考如上cppcommon
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### run `./segment_demo` to get help.
|
||||||
|
|
||||||
|
如下:
|
||||||
```
|
```
|
||||||
usage:
|
usage:
|
||||||
./segment_demo[options] <filename>
|
./segment_demo[options] <filename>
|
||||||
|
@ -18,8 +18,8 @@ DOPACK := $(AR)
|
|||||||
SOURCES := $(wildcard *.cpp)
|
SOURCES := $(wildcard *.cpp)
|
||||||
OBJS := $(patsubst %.cpp,%.o,$(SOURCES))
|
OBJS := $(patsubst %.cpp,%.o,$(SOURCES))
|
||||||
|
|
||||||
CMDIR := ../cppcommon
|
#CMDIR := ../cppcommon
|
||||||
CMLIB := $(CMDIR)/libcm.a
|
#CMLIB := $(CMDIR)/libcm.a
|
||||||
|
|
||||||
TMPDIR := ./cppjiebatmp
|
TMPDIR := ./cppjiebatmp
|
||||||
|
|
||||||
@ -27,7 +27,8 @@ LIBA := libcppjieba.a
|
|||||||
|
|
||||||
# remove the objs after compilation
|
# remove the objs after compilation
|
||||||
.INTERMEDIATE:
|
.INTERMEDIATE:
|
||||||
.PHONY: clean $(CMLIB)
|
#.PHONY: clean $(CMLIB)
|
||||||
|
.PHONY: clean
|
||||||
|
|
||||||
all: $(LIBA)
|
all: $(LIBA)
|
||||||
|
|
||||||
@ -36,16 +37,19 @@ all: $(LIBA)
|
|||||||
%.o: %.cpp
|
%.o: %.cpp
|
||||||
$(CXX) -c $(CXXFLAGS) $<
|
$(CXX) -c $(CXXFLAGS) $<
|
||||||
|
|
||||||
${LIBA}: $(TMPDIR) $(OBJS) $(CMLIB)
|
#${LIBA}: $(TMPDIR) $(OBJS) $(CMLIB)
|
||||||
cp $(CMLIB) $(TMPDIR) && cd $(TMPDIR) && ar x `basename $(CMLIB)`
|
# cp $(CMLIB) $(TMPDIR) && cd $(TMPDIR) && ar x `basename $(CMLIB)`
|
||||||
$(DOPACK) $@ $(OBJS) $(TMPDIR)/*.o
|
# $(DOPACK) $@ $(OBJS) $(TMPDIR)/*.o
|
||||||
rm -rf $(TMPDIR)
|
# rm -rf $(TMPDIR)
|
||||||
|
|
||||||
$(TMPDIR):
|
${LIBA}: $(OBJS)
|
||||||
mkdir $@
|
$(DOPACK) $@ $(OBJS)
|
||||||
|
|
||||||
$(CMLIB):
|
#$(TMPDIR):
|
||||||
cd $(CMDIR) && $(MAKE)
|
# mkdir $@
|
||||||
|
|
||||||
|
#$(CMLIB):
|
||||||
|
# cd $(CMDIR) && $(MAKE)
|
||||||
|
|
||||||
#unit test
|
#unit test
|
||||||
Trie.ut: Trie.cpp Trie.h globals.h TransCode.cpp TransCode.h $(CMLIB)
|
Trie.ut: Trie.cpp Trie.h globals.h TransCode.cpp TransCode.h $(CMLIB)
|
||||||
@ -66,8 +70,8 @@ MixSegment.ut: MixSegment.cpp MixSegment.h HMMSegment.cpp MPSegment.cpp Trie.cpp
|
|||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *.o *.d *.ut $(LIBA)
|
rm -f *.o *.d *.ut $(LIBA)
|
||||||
rm -rf $(TMPDIR)
|
# rm -rf $(TMPDIR)
|
||||||
cd $(CMDIR) && make clean
|
# cd $(CMDIR) && make clean
|
||||||
|
|
||||||
sinclude $(SOURCES:.cpp=.d)
|
sinclude $(SOURCES:.cpp=.d)
|
||||||
%.d:%.cpp
|
%.d:%.cpp
|
@ -20,11 +20,14 @@ DOPACK := $(AR)
|
|||||||
SOURCES := $(wildcard *.cpp)
|
SOURCES := $(wildcard *.cpp)
|
||||||
OBJS := $(patsubst %.cpp,%.o,$(SOURCES))
|
OBJS := $(patsubst %.cpp,%.o,$(SOURCES))
|
||||||
|
|
||||||
SRCDIR = ../src
|
CPPJIEBADIR = ../cppjieba
|
||||||
SRCLIB = $(SRCDIR)/libcppjieba.a
|
LIBCPPJIEBA = $(CPPJIEBADIR)/libcppjieba.a
|
||||||
|
|
||||||
|
CPPCOMMONDIR = ../cppcommon
|
||||||
|
LIBCPPCM = $(CPPCOMMONDIR)/libcm.a
|
||||||
|
|
||||||
# remove the objs after compilation
|
# remove the objs after compilation
|
||||||
.PHONY: clean $(SRCLIB)
|
.PHONY: clean $(LIBCPPJIEBA) $(LIBCPPCM)
|
||||||
|
|
||||||
# Main Targets
|
# Main Targets
|
||||||
all: keywordext_demo segment_demo
|
all: keywordext_demo segment_demo
|
||||||
@ -34,18 +37,22 @@ all: keywordext_demo segment_demo
|
|||||||
%.o: %.cpp
|
%.o: %.cpp
|
||||||
$(CXX) -c $(CXXFLAGS) $<
|
$(CXX) -c $(CXXFLAGS) $<
|
||||||
|
|
||||||
keywordext_demo: keywordext_demo.o $(SRCLIB)
|
keywordext_demo: keywordext_demo.o $(LIBCPPJIEBA) $(LIBCPPCM)
|
||||||
$(DOLINK) -o $@ $^
|
$(DOLINK) -o $@ $^
|
||||||
|
|
||||||
segment_demo: segment_demo.o $(SRCLIB)
|
segment_demo: segment_demo.o $(LIBCPPJIEBA) $(LIBCPPCM)
|
||||||
$(DOLINK) -o $@ $^
|
$(DOLINK) -o $@ $^
|
||||||
|
|
||||||
$(SRCLIB):
|
$(LIBCPPJIEBA):
|
||||||
cd $(SRCDIR) && $(MAKE)
|
cd $(CPPJIEBADIR) && $(MAKE)
|
||||||
|
|
||||||
|
$(LIBCPPCM):
|
||||||
|
cd $(CPPCOMMONDIR) && $(MAKE)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *.o *.ut *.d *.d.* keywordext_demo segment_demo
|
rm -f *.o *.ut *.d *.d.* keywordext_demo segment_demo
|
||||||
cd $(SRCDIR) && make clean
|
cd $(CPPJIEBADIR) && make clean
|
||||||
|
cd $(CPPCOMMONDIR) && make clean
|
||||||
|
|
||||||
sinclude $(SOURCES:.cpp=.d)
|
sinclude $(SOURCES:.cpp=.d)
|
||||||
%.d:%.cpp
|
%.d:%.cpp
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include "../src/headers.h"
|
#include "../cppjieba/headers.h"
|
||||||
|
|
||||||
using namespace CppJieba;
|
using namespace CppJieba;
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include "../src/headers.h"
|
#include "../cppjieba/headers.h"
|
||||||
|
|
||||||
using namespace CppJieba;
|
using namespace CppJieba;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user