cmake 和 tesseract,如何使用 cmake 进行链接 [英] cmake and tesseract, how to link using cmake

查看:148
本文介绍了cmake 和 tesseract,如何使用 cmake 进行链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试针对 tesseract 构建我的应用程序,我已经通过 brew 安装了它(在 mac os x 上工作).

I'm trying to build my application against tesseract, which i have installed through brew (working on mac os x).

虽然我可以使用 g++ 和 pkg-config 毫无问题地编译我的应用程序,但我不知道如何使用 cmake 做同样的事情.

While i can compile my application without problem using g++ and pkg-config, i'm not sure how to do the same with cmake.

我尝试了 FIND_PACKAGE tesseract REQUIRED 但它似乎无法找到它.有人有示例 CMakeLists.txt 吗?

I tried FIND_PACKAGE tesseract REQUIRED but it can't seem to find it. Does anyone have a sample CMakeLists.txt ?

感谢您的帮助.

推荐答案

在您的项目中使用 CMake 使用 tesseract 的唯一(或最简单)方法似乎是下载 tesseract 源代码(来自 这里 )构建步骤如下:

It seems the only (or the easiest) way to use tesseract in your project with CMake is to download tesseract sources (from here ) The build with the following steps:

cd <Tesseract source directory>
mkdir build
cd build
cmake ../
make
sudo make install

将Tesseract_DIR"环境变量指定到您刚刚为 tesseract 创建的目录中.

Specify "Tesseract_DIR" environment variable to the directory you just created for tesseract.

然后在你的项目的 CMakeLists.txt 文件中你应该有以下几行:

Then in the CMakeLists.txt file of your project you should have the following lines:

find_package( Tesseract 3.05 REQUIRED ) # 3.05 is currently the latest version of the git repository.
include_directories(${Tesseract_INCLUDE_DIRS})
target_link_libraries(<your_program_executable> ${Tesseract_LIBRARIES})  # you can link here multiple libraries as well.

毕竟只是用 cmake 构建你的项目.

After the all just build your project with cmake.

这篇关于cmake 和 tesseract,如何使用 cmake 进行链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆