没有mac版本的可执行文件吗
可否提供一个mac版本的可执行文件?
很抱歉,没有。手边也没有mac设备,也编译不了。
如果您使用的是intel x86_64版的mac的话,可以尝试在docker里运行PaddleOCR-json。docker应该能提供一个linux x86_64的环境,可以直接编译/运行引擎。不过arm、m系列芯片的mac则不推荐用docker。
不过好消息是PaddleOCR-json的依赖还算简单,而且所有依赖都有mac版的预编译包可以下载。 因此您如果有条件的话可以自己编译一份mac版的引擎。
- 首先配置一套c++环境
- 首先下载opencv (看那个brew安装的章节) 和paddle ocr预测库
- 然后跟随linux文档走完第一大章
前期准备 - 接着修改一下这个文件的宏
PaddleOCR-json/cpp/src/task_linux.cpp,把下面这行 https://github.com/hiroi-sora/PaddleOCR-json/blob/1beac1c0f3ec2c6d503aee1424efe336e03dffd6/cpp/src/task_linux.cpp#L3 改成这样:
#if defined(_LINUX) || defined(__linux__) || defined(__APPLE__)
这样就可以用Linux版的引擎实现来编译了
- 然后就可以跟着文档走了,回到第二大章
构建 & 编译项目,正式编译引擎
不过需要注意的是,我从没有在mac设备上编译/测试过引擎,因此也不确定linux的实现能否直接兼容mac。 如果您有遇到编译/运行上的问题,欢迎在这里提问。 如果您成功编译/运行了引擎,然后有意向贡献代码的话也欢迎pr
很抱歉,没有。手边也没有mac设备,也编译不了。
如果您使用的是intel x86_64版的mac的话,可以尝试在docker里运行PaddleOCR-json。docker应该能提供一个linux x86_64的环境,可以直接编译/运行引擎。不过arm、m系列芯片的mac则不推荐用docker。
不过好消息是PaddleOCR-json的依赖还算简单,而且所有依赖都有mac版的预编译包可以下载。 因此您如果有条件的话可以自己编译一份mac版的引擎。
首先配置一套c++环境
然后跟随linux文档走完第一大章
前期准备接着修改一下这个文件的宏
PaddleOCR-json/cpp/src/task_linux.cpp,把下面这行[PaddleOCR-json/cpp/src/task_linux.cpp](https://github.com/hiroi-sora/PaddleOCR-json/blob/1beac1c0f3ec2c6d503aee1424efe336e03dffd6/cpp/src/task_linux.cpp#L3) Line 3 in [1beac1c](/hiroi-sora/PaddleOCR-json/commit/1beac1c0f3ec2c6d503aee1424efe336e03dffd6) #if defined(_LINUX) || defined(__linux__)改成这样:
#if defined(_LINUX) || defined(linux) || defined(APPLE) 这样就可以用Linux版的引擎实现来编译了
- 然后就可以跟着文档走了,回到第二大章
构建 & 编译项目,正式编译引擎不过需要注意的是,我从没有在mac设备上编译/测试过引擎,因此也不确定linux的实现能否直接兼容mac。 如果您有遇到编译/运行上的问题,欢迎在这里提问。 如果您成功编译/运行了引擎,然后有意向贡献代码的话也欢迎pr
大佬,我尝试编译了一下,出现了如下报错:
(base) ➜ cpp git:(main) ✗ ./tools/linux_build.sh
MODE: Release
PADDLE_LIB: /Users/pan/projects/PaddleOCR-json/cpp/.source/paddle_inference_manylinux_cpu_avx_mkl_gcc8.2/
-- The CXX compiler identification is AppleClang 17.0.0.17000013
-- The C compiler identification is AppleClang 17.0.0.17000013
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Features:
-- ENABLE_CLIPBOARD: OFF
-- ENABLE_REMOTE_EXIT: ON
-- ENABLE_JSON_IMAGE_PATH: ON
-- CMake Features:
-- INSTALL_WITH_TOOLS: ON
-- Found OpenCV: /opt/homebrew/Cellar/opencv/4.11.0_1 (found version "4.11.0") found components: core imgproc imgcodecs
-- cmake cxx flags: -fopenmp -std=c++11
-- Looking for C++ include unistd.h
-- Looking for C++ include unistd.h - not found
-- Looking for C++ include stdint.h
-- Looking for C++ include stdint.h - not found
-- Looking for C++ include inttypes.h
-- Looking for C++ include inttypes.h - not found
-- Looking for C++ include sys/types.h
-- Looking for C++ include sys/types.h - not found
-- Looking for C++ include sys/stat.h
-- Looking for C++ include sys/stat.h - not found
-- Looking for C++ include fnmatch.h
-- Looking for C++ include fnmatch.h - not found
-- Looking for C++ include stddef.h
-- Looking for C++ include stddef.h - not found
-- Check size of uint32_t
-- Check size of uint32_t - failed
-- Check size of u_int32_t
-- Check size of u_int32_t - failed
CMake Error at third_party/gflags/CMakeLists.txt:292 (message):
Do not know how to define a 32-bit integer quantity on your system! Neither
uint32_t, u_int32_t, nor __int32 seem to be available. Set
[GFLAGS_]INTTYPES_FORMAT to either C99, BSD, or VC7 and try again.
-- Configuring incomplete, errors occurred!
这是依赖库gflags的cmake脚本报错,它在您的c++环境里找不到uint32_t, u_int32_t, 或者 __int32这些类。我看到gflags仓库里的这个issue有提到您的环境可能缺少stdint.h,请跟随上面的回答去检查一遍您的CMakeError.log日志。
从您提供的cmake输出来看,cmake确实没找到stdint.h
-- Looking for C++ include stdint.h
-- Looking for C++ include stdint.h - not found
-- Looking for C++ include inttypes.h
-- Looking for C++ include inttypes.h - not found
-- Looking for C++ include sys/types.h
-- Looking for C++ include sys/types.h - not found
您的环境可能没配置好, 可以看看下面这两篇文章:
- https://stackoverflow.com/questions/25452817/weird-missing-header-on-mac
- https://stackoverflow.com/questions/62762049/stdint-h-include-nextd-from-stdint-h-not-found
当然,如果您用的是xcode的c++环境,那也可以尝试换一个编译器,比如clang(不是AppleClang,是原版clang)
另外,我注意到您使用的PADDLE_LIB是paddle_inference_manylinux_cpu_avx_mkl_gcc8.2。请确保您下载的是mac专用的paddle推理库而非linux版的。paddleocr官方的mac推理库也是用clang编译的,因此更推荐用clang。
还有,上面的cmake输出里有提到没找到unistd.h,因此您在编译时可能会遇到套接字相关的方法无法调用/找不到的情况。
可以看看这篇文章:https://stackoverflow.com/questions/61300206/using-sockets-in-xcode-cpp
@Gavin1937 感谢大佬,我再研究一下