安裝:
sudo apt install scons
文件目錄結構:(具體文件見 https://github.com/mhsszm/test_libfacedetection )
├── facedetection
│ ├── build_install
│ ├── example
│ ├── models
│ └── src
├── images
│ ├── keliamoniz1.jpg
│ └── keliamoniz2.jpg
└── SConstruct
6 directories, 3 files
說明:build_install 裏存放opencv的頭文件與庫
example 爲示例cpp
models 爲模型文件
src 爲原文件
對應的SConstruct文件內容如下,
env = Environment()
env.Append(CCFLAGS = ['-march=native', '-O3'])
CPPS = [Glob('facedetection/src/*.cpp'),Glob('facedetection/example/*.cpp')]
LIBS = ['opencv_core', 'opencv_highgui']
LIBPATH = ['facedetection/build-install/lib']
HEADFILEPATH = ['facedetection/src/','facedetection/build-install/include']
env.Program(target = 'test',source = CPPS, CPPPATH = HEADFILEPATH,LIBS=LIBS, LIBPATH=LIBPATH)
運行:scons
會成爲可執行文件test以及中間文件.o
運行後的輸出結果如下: