Skip to content

Commit

Permalink
fix cygwin build (issue 1289)
Browse files Browse the repository at this point in the history
  • Loading branch information
zdenop committed Sep 28, 2014
1 parent 9b3cbcd commit 2421388
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 19 deletions.
4 changes: 2 additions & 2 deletions api/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ libtesseract_la_LIBADD = \
libtesseract_la_LDFLAGS += -version-info $(GENERIC_LIBRARY_VERSION)

bin_PROGRAMS = tesseract
tesseract_SOURCES = $(top_srcdir)/api/tesseractmain.cpp
tesseract_SOURCES = tesseractmain.cpp
tesseract_CPPFLAGS = $(AM_CPPFLAGS)
if VISIBILITY
tesseract_CPPFLAGS += -DTESS_IMPORTS
Expand All @@ -78,7 +78,7 @@ if USE_OPENCL
tesseract_LDADD += $(OPENCL_LIB)
endif

if MINGW
if T_WIN
tesseract_LDADD += -lws2_32
libtesseract_la_LDFLAGS += -no-undefined -Wl,--as-needed -lws2_32
endif
Expand Down
4 changes: 2 additions & 2 deletions ccutil/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
AUTOMAKE_OPTIONS = subdir-objects
SUBDIRS =
AM_CXXFLAGS =

Expand Down Expand Up @@ -40,8 +41,7 @@ libtesseract_ccutil_la_SOURCES = \
unichar.cpp unicharmap.cpp unicharset.cpp unicodes.cpp \
params.cpp universalambigs.cpp


if MINGW
if T_WIN
AM_CPPFLAGS += -I$(top_srcdir)/vs2008/port -DWINDLLNAME=\"lib@GENERIC_LIBRARY_NAME@\"
noinst_HEADERS += ../vs2010/port/strtok_r.h
libtesseract_ccutil_la_SOURCES += ../vs2010/port/strtok_r.cpp
Expand Down
4 changes: 2 additions & 2 deletions ccutil/ambigs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
#include "helpers.h"
#include "universalambigs.h"

#ifdef _WIN32
#if defined _WIN32 || defined(__CYGWIN__)
#ifndef __GNUC__
#define strtok_r strtok_s
#else
#include "strtok_r.h"
#endif /* __GNUC__ */
#endif /* _WIN32 */
#endif /* _WIN32 __CYGWIN__*/

namespace tesseract {

Expand Down
2 changes: 1 addition & 1 deletion ccutil/scanutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include "tprintf.h"

// workaround for "'off_t' was not declared in this scope" with -std=c++11
#if !defined(off_t) && !defined(__APPLE__)
#if !defined(off_t) && !defined(__APPLE__) && !defined(__CYGWIN__)
typedef long off_t;
#endif // off_t

Expand Down
16 changes: 7 additions & 9 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ AC_CONFIG_HEADERS(config_auto.h:config/config.h.in)
AM_MAINTAINER_MODE

# default conditional
AM_CONDITIONAL(MINGW, false)
AM_CONDITIONAL(T_WIN, false)
AM_CONDITIONAL(OSX, false)
AM_CONDITIONAL(GRAPHICS_DISABLED, false)

Expand All @@ -77,12 +77,14 @@ AC_CANONICAL_HOST
case "${host_os}" in
mingw32*)
AC_DEFINE_UNQUOTED(MINGW,1,[This is a MinGW system])
AM_CONDITIONAL(MINGW, true)
AM_CONDITIONAL(T_WIN, true)
AM_CONDITIONAL(ADD_RT, false)
AC_SUBST([AM_LDFLAGS], ['-Wl,-no-undefined -Wl,--as-needed'])
;;
cygwin*)
AM_CONDITIONAL(ADD_RT, false)
AM_CONDITIONAL(ADD_RT, false)
AM_CONDITIONAL(T_WIN, true)
AC_SUBST([AM_LDFLAGS], ['-Wl,-no-undefined -Wl,--as-needed'])
;;
solaris*)
LIBS="-lsocket -lnsl -lrt -lxnet"
Expand Down Expand Up @@ -408,13 +410,9 @@ AM_CONDITIONAL(ENABLE_TRAINING, $have_cairo)

# set c++11 support based on platform/compiler
if test "x$has_cpp11" = "xyes"; then
case "$host" in
case "${host_os}" in
cygwin*)
if test "x$snprintfworks" = "xno"; then
# cygwin workaround
# http://stackoverflow.com/questions/20149633/how-to-use-snprintf-in-g-std-c11-version-4-8-2/20149792#20149792
CXXFLAGS="$CXXFLAGS -std=gnu++11"
fi
CXXFLAGS="$CXXFLAGS -std=gnu++11"
;;
*-darwin* | *-macos10*)
if test "x$CLANG" = "xyes"; then
Expand Down
5 changes: 3 additions & 2 deletions training/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
AUTOMAKE_OPTIONS = subdir-objects
AM_CPPFLAGS += \
-DUSE_STD_NAMESPACE -DPANGO_ENABLE_ENGINE\
-I$(top_srcdir)/ccmain -I$(top_srcdir)/api \
Expand All @@ -9,7 +10,7 @@ AM_CPPFLAGS += \

EXTRA_DIST = tesstrain.sh

if MINGW
if T_WIN
# try static build
#AM_LDFLAGS += -all-static
#libic=-lsicuin -licudt -lsicuuc
Expand Down Expand Up @@ -279,7 +280,7 @@ wordlist2dawg_LDADD += \
../api/libtesseract.la
endif

if MINGW
if T_WIN
ambiguous_words_LDADD += -lws2_32
classifier_tester_LDADD += -lws2_32
cntraining_LDADD += -lws2_32
Expand Down
2 changes: 1 addition & 1 deletion viewer/svutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ void SVNetwork::Flush() {
// This will always return one line of char* (denoted by \n).
char* SVNetwork::Receive() {
char* result = NULL;
#ifdef _WIN32
#if defined(_WIN32) || defined(__CYGWIN__)
if (has_content) { result = strtok (NULL, "\n"); }
#else
if (buffer_ptr_ != NULL) { result = strtok_r(NULL, "\n", &buffer_ptr_); }
Expand Down

0 comments on commit 2421388

Please sign in to comment.