本文参考自https://blog.csdn.net/weixin_40026739/article/details/129741274
执行指令sudo ./tools/build.sh后,会出现如下报错
cc1plus: error: too many filenames given. Type cc1plus --help for usage
cc1plus: fatal error: CMakeFiles/ppocr.dir/src/args.cpp.d: 没有那个文件或目录
compilation terminated.
cc1plus: error: too many filenames given. Type cc1plus --help for usage
cc1plus: fatal error: CMakeFiles/ppocr.dir/src/ocr_rec.cpp.d: 没有那个文件或目录
compilation terminated.
CMakeFiles/ppocr.dir/build.make:75: recipe for target 'CMakeFiles/ppocr.dir/src/args.cpp.o' failed
cc1plus: error: too many filenames given. Type cc1plus --help for usage
cc1plus: error: too many filenames given. Type cc1plus --help for usage
cc1plus: error: too many filenames given. Type cc1plus --help for usage
cc1plus: fatal error: CMakeFiles/ppocr.dir/src/ocr_det.cpp.d: 没有那个文件或目录
cc1plus: fatal error: CMakeFiles/ppocr.dir/src/main.cpp.d: 没有那个文件或目录
compilation terminated.
compilation terminated.
make[2]: *** [CMakeFiles/ppocr.dir/src/args.cpp.o] Error 1
cc1plus: fatal error: CMakeFiles/ppocr.dir/src/clipper.cpp.d: 没有那个文件或目录
compilation terminated.
CMakeFiles/ppocr.dir/build.make:145: recipe for target 'CMakeFiles/ppocr.dir/src/ocr_rec.cpp.o' failed
make[2]: *** [CMakeFiles/ppocr.dir/src/ocr_rec.cpp.o] Error 1
CMakeFiles/ppocr.dir/build.make:131: recipe for target 'CMakeFiles/ppocr.dir/src/ocr_det.cpp.o' failed
make[2]: *** [CMakeFiles/ppocr.dir/src/ocr_det.cpp.o] Error 1
CMakeFiles/ppocr.dir/build.make:103: recipe for target 'CMakeFiles/ppocr.dir/src/main.cpp.o' failed
make[2]: *** [CMakeFiles/ppocr.dir/src/main.cpp.o] Error 1
CMakeFiles/ppocr.dir/build.make:89: recipe for target 'CMakeFiles/ppocr.dir/src/clipper.cpp.o' failed
make[2]: *** [CMakeFiles/ppocr.dir/src/clipper.cpp.o] Error 1
cc1plus: error: too many filenames given. Type cc1plus --help for usage
cc1plus: fatal error: CMakeFiles/ppocr.dir/src/postprocess_op.cpp.d: 没有那个文件或目录
compilation terminated.
CMakeFiles/ppocr.dir/build.make:187: recipe for target 'CMakeFiles/ppocr.dir/src/postprocess_op.cpp.o' failed
make[2]: *** [CMakeFiles/ppocr.dir/src/postprocess_op.cpp.o] Error 1
cc1plus: error: too many filenames given. Type cc1plus --help for usage
cc1plus: error: too many filenames given. Type cc1plus --help for usage
cc1plus: error: too many filenames given. Type cc1plus --help for usage
cc1plus: fatal error: CMakeFiles/ppocr.dir/src/structure_layout.cpp.d: 没有那个文件或目录
compilation terminated.
cc1plus: fatal error: CMakeFiles/ppocr.dir/src/ocr_cls.cpp.d: 没有那个文件或目录
compilation terminated.
cc1plus: fatal error: CMakeFiles/ppocr.dir/src/structure_table.cpp.d: 没有那个文件或目录
compilation terminated.
CMakeFiles/ppocr.dir/build.make:215: recipe for target 'CMakeFiles/ppocr.dir/src/structure_layout.cpp.o' failed
make[2]: *** [CMakeFiles/ppocr.dir/src/structure_layout.cpp.o] Error 1
CMakeFiles/ppocr.dir/build.make:117: recipe for target 'CMakeFiles/ppocr.dir/src/ocr_cls.cpp.o' failed
make[2]: *** [CMakeFiles/ppocr.dir/src/ocr_cls.cpp.o] Error 1
CMakeFiles/ppocr.dir/build.make:229: recipe for target 'CMakeFiles/ppocr.dir/src/structure_table.cpp.o' failed
make[2]: *** [CMakeFiles/ppocr.dir/src/structure_table.cpp.o] Error 1
cc1plus: error: too many filenames given. Type cc1plus --help for usage
cc1plus: error: too many filenames given. Type cc1plus --help for usage
cc1plus: error: too many filenames given. Type cc1plus --help for usage
cc1plus: fatal error: CMakeFiles/ppocr.dir/src/utility.cpp.d: 没有那个文件或目录
compilation terminated.
cc1plus: fatal error: CMakeFiles/ppocr.dir/src/preprocess_op.cpp.d: 没有那个文件或目录
compilation terminated.
cc1plus: fatal error: CMakeFiles/ppocr.dir/src/paddleocr.cpp.d: 没有那个文件或目录
compilation terminated.
cc1plus: error: too many filenames given. Type cc1plus --help for usage
cc1plus: fatal error: CMakeFiles/ppocr.dir/src/paddlestructure.cpp.d: 没有那个文件或目录
compilation terminated.
CMakeFiles/ppocr.dir/build.make:243: recipe for target 'CMakeFiles/ppocr.dir/src/utility.cpp.o' failed
make[2]: *** [CMakeFiles/ppocr.dir/src/utility.cpp.o] Error 1
CMakeFiles/ppocr.dir/build.make:201: recipe for target 'CMakeFiles/ppocr.dir/src/preprocess_op.cpp.o' failed
make[2]: *** [CMakeFiles/ppocr.dir/src/preprocess_op.cpp.o] Error 1
CMakeFiles/ppocr.dir/build.make:159: recipe for target 'CMakeFiles/ppocr.dir/src/paddleocr.cpp.o' failed
make[2]: *** [CMakeFiles/ppocr.dir/src/paddleocr.cpp.o] Error 1
CMakeFiles/ppocr.dir/build.make:173: recipe for target 'CMakeFiles/ppocr.dir/src/paddlestructure.cpp.o' failed
make[2]: *** [CMakeFiles/ppocr.dir/src/paddlestructure.cpp.o] Error 1
CMakeFiles/Makefile2:99: recipe for target 'CMakeFiles/ppocr.dir/all' failed
make[1]: *** [CMakeFiles/ppocr.dir/all] Error 2
Makefile:90: recipe for target 'all' failed
make: *** [all] Error 2
报错在终端显示如下图
解决办法,找到
~/ocr/01/PaddleOCR/deploy/cpp_infer/CMakeLists.txt
将 "-o3" 改成 "-O3" 就可以了,修改后的结果如下,
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O3 ${FLAG_OPENMP} -std=c++11")
这应该是一个打字错误引起的,不理解为什么官方没有修正过来
修改如下路径如下