Ask Your Question

OpenCV 4 make failed - precomp.hpp:54:10: fatal error: ‘tesseract/baseapi.h’ file not found

asked 2019-02-21 01:50:11 -0500

G'day, I was following the "Install OpenCV 4 on MacOS" tutorial found at PyImageSearch. I got to the step where you "make -j4" without any errors. However, at around 55% through the build, make crashes with the following error:

make: *** [all] Error 2

I repeated the make command using the --verbose option, and was able to find a number of errors during the build that look like this:

[ 55%] Building CXX object modules/text/CMakeFiles/opencv_text.dir/src/ocr_holistic.cpp.o
In file included from /*[sanitised]*/opencv_contrib/modules/text/src/ocr_beamsearch_decoder.cpp:43:
/*[sanitised]*/opencv_contrib/modules/text/src/precomp.hpp:54:10: fatal error: 'tesseract/baseapi.h' file not found
#include <tesseract/baseapi.h>

My environment is macOS Mojave 10.14.3, python3=3.7.2, OpenCV=4.0.0 using Homebrew.

I've trawled the forums and have tried the following fixes/work arounds without success:

  • uninstall / reinstall tesseract
  • unlink / link tesseract via Homebrew
  • uninstalled tesseract and tried to make without it

I've posted on the PyImageSearch forum but havent had any luck there yet.

Any assistance would be appreciated.


edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted

answered 2019-03-15 07:25:00 -0500

Hi !

I experienced the same problem and it seems the tesseract package is broken a little so its include dir is just not added to system include.

And if you sure the package is installed it is just necessary to check the path to its include and allow make to find it.

In my case the path is:


So I added it like this:

CXXFLAGS=-isystem\ /usr/local/Cellar/tesseract/4.0.0_1/include cmake <ALL_CMAKE_ARGS_HERE>

Another method is:

cmake -DCMAKE_CXX_FLAGS=-isystem\ /usr/local/Cellar/tesseract/4.0.0_1/include <OTHER_CMAKE_ARGS_HERE>

Hope it helps.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2019-02-21 01:50:11 -0500

Seen: 63 times

Last updated: Feb 21