Backport from upstream 6140be6a5575e9159e3678adf4ee9e673b3ff2cc diff -Naur tesseract-4.00.00alpha.orig/api/Makefile.am tesseract-4.00.00alpha/api/Makefile.am --- tesseract-4.00.00alpha.orig/api/Makefile.am 2016-11-08 00:38:07.000000000 +0100 +++ tesseract-4.00.00alpha/api/Makefile.am 2017-01-26 10:27:59.269712914 +0100 @@ -88,9 +88,7 @@ tesseract_LDFLAGS = $(OPENCL_LDFLAGS) -if OPENMP tesseract_LDADD += $(OPENMP_CFLAGS) -endif if T_WIN tesseract_LDADD += -lws2_32 @@ -99,4 +97,3 @@ if ADD_RT tesseract_LDADD += -lrt endif - diff -Naur tesseract-4.00.00alpha.orig/ccmain/Makefile.am tesseract-4.00.00alpha/ccmain/Makefile.am --- tesseract-4.00.00alpha.orig/ccmain/Makefile.am 2016-11-08 00:38:07.000000000 +0100 +++ tesseract-4.00.00alpha/ccmain/Makefile.am 2017-01-26 10:27:59.269712914 +0100 @@ -8,6 +8,7 @@ -I$(top_srcdir)/textord -I$(top_srcdir)/opencl AM_CPPFLAGS += $(OPENCL_CPPFLAGS) +AM_CPPFLAGS += $(OPENMP_CXXFLAGS) if VISIBILITY AM_CPPFLAGS += -DTESS_EXPORTS \ diff -Naur tesseract-4.00.00alpha.orig/ccmain/par_control.cpp tesseract-4.00.00alpha/ccmain/par_control.cpp --- tesseract-4.00.00alpha.orig/ccmain/par_control.cpp 2016-11-08 00:38:07.000000000 +0100 +++ tesseract-4.00.00alpha/ccmain/par_control.cpp 2017-01-26 10:27:59.269712914 +0100 @@ -18,9 +18,9 @@ /////////////////////////////////////////////////////////////////////// #include "tesseractclass.h" -#ifdef OPENMP +#ifdef _OPENMP #include -#endif // OPENMP +#endif // _OPENMP namespace tesseract { @@ -53,7 +53,9 @@ } // Pre-classify all the blobs. if (tessedit_parallelize > 1) { +#ifdef _OPENMP #pragma omp parallel for num_threads(10) +#endif // _OPENMP for (int b = 0; b < blobs.size(); ++b) { *blobs[b].choices = blobs[b].tesseract->classify_blob(blobs[b].blob, "par", White, NULL); diff -Naur tesseract-4.00.00alpha.orig/configure.ac tesseract-4.00.00alpha/configure.ac --- tesseract-4.00.00alpha.orig/configure.ac 2016-11-08 00:38:07.000000000 +0100 +++ tesseract-4.00.00alpha/configure.ac 2017-01-26 10:28:45.636688839 +0100 @@ -170,14 +170,7 @@ fi # check whether to build OpenMP support -AM_CONDITIONAL([OPENMP], false) AC_OPENMP -AS_IF([test "x$OPENMP_CFLAGS" != "x"], - [AM_CONDITIONAL([OPENMP], true) - AC_SUBST([AM_CPPFLAGS], ["$OPENMP_CXXFLAGS"]) - AC_DEFINE([OPENMP], [], [Defined when compiled with OpenMP support])] -) - # check whether to build opencl version AC_MSG_CHECKING([--enable-opencl argument]) diff -Naur tesseract-4.00.00alpha.orig/lstm/lstm.cpp tesseract-4.00.00alpha/lstm/lstm.cpp --- tesseract-4.00.00alpha.orig/lstm/lstm.cpp 2016-11-08 00:38:07.000000000 +0100 +++ tesseract-4.00.00alpha/lstm/lstm.cpp 2017-01-26 10:27:59.269712914 +0100 @@ -18,7 +18,7 @@ #include "lstm.h" -#ifndef ANDROID_BUILD +#ifdef _OPENMP #include #endif #include diff -Naur tesseract-4.00.00alpha.orig/lstm/Makefile.am tesseract-4.00.00alpha/lstm/Makefile.am --- tesseract-4.00.00alpha.orig/lstm/Makefile.am 2016-11-08 00:38:07.000000000 +0100 +++ tesseract-4.00.00alpha/lstm/Makefile.am 2017-01-26 10:27:59.269712914 +0100 @@ -4,7 +4,7 @@ -I$(top_srcdir)/dict -I$(top_srcdir)/lstm AUTOMAKE_OPTIONS = subdir-objects SUBDIRS = -AM_CXXFLAGS = -fopenmp +AM_CXXFLAGS = $(OPENMP_CXXFLAGS) if !NO_TESSDATA_PREFIX AM_CXXFLAGS += -DTESSDATA_PREFIX=@datadir@/ diff -Naur tesseract-4.00.00alpha.orig/lstm/parallel.cpp tesseract-4.00.00alpha/lstm/parallel.cpp --- tesseract-4.00.00alpha.orig/lstm/parallel.cpp 2016-11-08 00:38:07.000000000 +0100 +++ tesseract-4.00.00alpha/lstm/parallel.cpp 2017-01-26 10:27:59.269712914 +0100 @@ -18,7 +18,9 @@ #include "parallel.h" +#ifdef _OPENMP #include +#endif #include "functions.h" // For conditional undef of _OPENMP. #include "networkscratch.h"