來自EAST的lanms的代碼
makefile的python路徑
CXXFLAGS = -I include -std=c++11 -O3 $(shell /home/hlx2/anapy35/bin/python3-config --cflags)
LDFLAGS = $(shell /home/hlx2/anapy35/bin/python3-config --ldflags)
DEPS = lanms.h $(shell find include -xtype f)
CXX_SOURCES = adaptor.cpp include/clipper/clipper.cpp
LIB_SO = adaptor.so
$(LIB_SO): $(CXX_SOURCES) $(DEPS)
$(CXX) -o $@ $(CXXFLAGS) $(LDFLAGS) $(CXX_SOURCES) --shared -fPIC
clean:
rm -rf $(LIB_SO)
hlx2@NLP:~/PycharmProjects/EAST-PVANET/lanms$ python3-config --cflags
-I/home/hlx2/anapy35/include/python3.5m -I/home/hlx2/anapy35/include/python3.5m -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes
-I/home/hlx2/anapy35/include/python3.5m:表示包含此目錄
-Idir
-O3:表示編譯器的優化選項
相關參數參考:
https://blog.csdn.net/qq_27009517/article/details/106473825
由於生成的.so文件和python的版本有關,所以要注意python3-config 的路徑。
find include -xtype f
hlx2@NLP:~/PycharmProjects/EAST-PVANET/lanms_east$ find include -xtype f
include/pybind11/stl_bind.h
include/pybind11/chrono.h
include/pybind11/functional.h
include/pybind11/typeid.h
include/pybind11/pybind11.h
include/pybind11/stl.h
include/pybind11/embed.h
include/pybind11/complex.h
include/pybind11/numpy.h
include/pybind11/pytypes.h
include/pybind11/common.h
include/pybind11/eval.h
include/pybind11/class_support.h
include/pybind11/attr.h
include/pybind11/eigen.h
include/pybind11/buffer_info.h
include/pybind11/operators.h
include/pybind11/descr.h
include/pybind11/cast.h
include/pybind11/options.h
include/clipper/clipper.hpp
include/clipper/clipper.cpp
$(LIB_SO): $(CXX_SOURCES) $(DEPS)
$(CXX) -o $@ $(CXXFLAGS) $(LDFLAGS) $(CXX_SOURCES) --shared -fPIC
$(CXX_SOURCES) $(DEPS):需要的文件
$(LIB_SO):要生成的文件名
$(CXX) -o $@ $(CXXFLAGS) $(LDFLAGS) $(CXX_SOURCES) --shared -fPIC:要執行的命令
命令前面是tab
生成方法
sudo make