Skip to content

Commit

Permalink
Implement check for Tensorflow header file
Browse files Browse the repository at this point in the history
This looks for one of the header files which are included by Tesseract.
It currently uses a hard coded path which works for Debian / Ubuntu.

Simplify also the rules for linking Tensorflow.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed May 24, 2019
1 parent 9cdf041 commit 2441e4d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
16 changes: 13 additions & 3 deletions configure.ac
Expand Up @@ -196,13 +196,23 @@ if test "$enable_opencl" = "yes"; then
fi

# Check whether to build with support for Tensorflow.
AC_MSG_CHECKING([--with-tensorflow])
AC_ARG_WITH([tensorflow],
AS_HELP_STRING([--with-tensorflow],
[support Tensorflow @<:@default=check@:>@]),
[], [with_tensorflow=check])
AC_MSG_RESULT([$with_tensorflow])
AM_CONDITIONAL([TENSORFLOW], [test "$with_tensorflow" != "no"])
AM_CONDITIONAL([TENSORFLOW], false)
TENSORFLOW_LIBS=
AS_IF([test "x$with_tensorflow" != xno],
[AC_CHECK_FILE([/usr/include/tensorflow/core/framework/graph.pb.h],
[AC_SUBST([TENSORFLOW_LIBS], ["-lprotobuf -ltensorflow_cc"])
AM_CONDITIONAL([TENSORFLOW], true)
],
[if test "x$with_tensorflow" != xcheck; then
AC_MSG_FAILURE(
[--with-tensorflow was given, but test for libtensorflow-dev failed])
fi
])
])

# https://lists.apple.com/archives/unix-porting/2009/Jan/msg00026.html
m4_define([MY_CHECK_FRAMEWORK],
Expand Down
6 changes: 1 addition & 5 deletions src/api/Makefile.am
Expand Up @@ -88,6 +88,7 @@ tesseract_LDFLAGS = $(OPENCL_LDFLAGS)

tesseract_LDADD += $(LEPTONICA_LIBS)
tesseract_LDADD += $(OPENMP_CXXFLAGS)
tesseract_LDADD += $(TENSORFLOW_LIBS)
tesseract_LDADD += $(libarchive_LIBS)

if T_WIN
Expand All @@ -98,8 +99,3 @@ endif
if ADD_RT
tesseract_LDADD += -lrt
endif

if TENSORFLOW
tesseract_LDADD += -lprotobuf
tesseract_LDADD += -ltensorflow_cc
endif
4 changes: 1 addition & 3 deletions src/training/Makefile.am
Expand Up @@ -282,9 +282,7 @@ unicharset_extractor_LDADD += $(LEPTONICA_LIBS)
wordlist2dawg_LDADD += $(LEPTONICA_LIBS)

extralib = $(libarchive_LIBS)
if TENSORFLOW
extralib += -lprotobuf -ltensorflow_cc
endif
extralib += $(TENSORFLOW_LIBS)

if !DISABLED_LEGACY_ENGINE
ambiguous_words_LDADD += $(extralib)
Expand Down

0 comments on commit 2441e4d

Please sign in to comment.