diff --git a/api/Makefile.am b/api/Makefile.am index 2cb933b35392e0d3f0ca76472f1e0ec383efab64..05cc8b3e751b38d69beaaca70e0a4a1b65415348 100644 --- a/api/Makefile.am +++ b/api/Makefile.am @@ -73,14 +73,16 @@ tesseract_CPPFLAGS += -DTESS_IMPORTS endif tesseract_LDADD = libtesseract.la -if !OSX -tesseract_LDADD += -lrt -endif + if USE_OPENCL tesseract_LDADD += $(OPENCL_LIB) endif + if MINGW tesseract_LDADD += -lws2_32 -libtesseract_la_LDFLAGS += -no-undefined -Wl,--as-needed -lws2_32 +libtesseract_la_LDFLAGS += -no-undefined -Wl,--as-needed -lws2_32 +endif +if ADD_RT +tesseract_LDADD += -lrt endif diff --git a/api/baseapi.cpp b/api/baseapi.cpp index 1861b0ef45699aa08b856560ca72b6ddb6a273e1..a6f22a49bac03b32034c612553c43bacb3bab4bf 100644 --- a/api/baseapi.cpp +++ b/api/baseapi.cpp @@ -26,6 +26,25 @@ #include #endif +#if defined(_WIN32) +#ifdef _MSC_VER +#include "mathfix.h" +#elif MINGW +// workaround for stdlib.h with -std=c++11 for _splitpath and _MAX_FNAME +#undef __STRICT_ANSI__ +#endif // _MSC_VER +#include +#include +#else +#include +#include +#include +#endif // _WIN32 + +#if !defined(VERSION) +#include "version.h" +#endif + #include "allheaders.h" #include "baseapi.h" @@ -54,22 +73,6 @@ #include "strngs.h" #include "openclwrapper.h" -#ifdef _WIN32 -#include -#include -#ifdef _MSC_VER -#include "mathfix.h" -#endif // _MSC_VER -#else -#include -#include -#include -#endif // _WIN32 - -#if !defined(VERSION) -#include "version.h" -#endif - namespace tesseract { /** Minimum sensible image size to be worth running tesseract. */ @@ -370,7 +373,7 @@ void TessBaseAPI::GetAvailableLanguagesAsVector( } FindClose(handle); } -#else +#else // _WIN32 DIR *dir; struct dirent *dirent; char *dot; diff --git a/ccmain/pagesegmain.cpp b/ccmain/pagesegmain.cpp index b960a211c56eb0e9b0c5fea9850b087e30359cd3..0d5de3dbc81277a8cb6b2950ba5f733dedb282d1 100644 --- a/ccmain/pagesegmain.cpp +++ b/ccmain/pagesegmain.cpp @@ -20,10 +20,13 @@ #ifdef _WIN32 #ifndef __GNUC__ #include -#endif /* __GNUC__ */ +#endif // __GNUC__ +#ifndef unlink +#include +#endif #else #include -#endif +#endif // _WIN32 #ifdef _MSC_VER #pragma warning(disable:4244) // Conversion warnings #endif diff --git a/ccstruct/pdblock.cpp b/ccstruct/pdblock.cpp index 643045321a024ce62022784d3abb2e50c4e1f39d..97365b53e7164304d73967711ece4bc5a8cc21c5 100644 --- a/ccstruct/pdblock.cpp +++ b/ccstruct/pdblock.cpp @@ -195,7 +195,7 @@ void PDBLK::plot( //draw outline // tprintf("Block %d bottom left is (%d,%d)\n", // serial,startpt.x(),startpt.y()); char temp_buff[34]; - #ifdef __UNIX__ + #if defined(__UNIX__) || defined(MINGW) sprintf(temp_buff, INT32FORMAT, serial); #else ultoa (serial, temp_buff, 10); diff --git a/ccstruct/polyblk.cpp b/ccstruct/polyblk.cpp index d0c610f25fe01b33b5f54b7ea3b8ebd4b89faf8a..1583788596915ffa940166060953ced60f81574c 100644 --- a/ccstruct/polyblk.cpp +++ b/ccstruct/polyblk.cpp @@ -252,7 +252,7 @@ void POLY_BLOCK::plot(ScrollView* window, inT32 num) { if (num > 0) { window->TextAttributes("Times", 80, false, false, false); char temp_buff[34]; - #ifdef __UNIX__ + #if defined(__UNIX__) || defined(MINGW) sprintf(temp_buff, INT32FORMAT, num); #else ltoa (num, temp_buff, 10); diff --git a/configure.ac b/configure.ac index a8c1fe0aeda29fe2fc3d923db0a222304ccd11f0..e240682dd65fd546158d96aa18e4525da3926a35 100644 --- a/configure.ac +++ b/configure.ac @@ -8,7 +8,7 @@ AC_PREREQ(2.50) AC_INIT([tesseract], [3.03], [http://code.google.com/p/tesseract-ocr/issues/list]) -CXXFLAGS="" +CXXFLAGS=${CXXFLAGS:-""} AC_CONFIG_MACRO_DIR([m4]) AC_REVISION([$Revision$]) AC_CONFIG_AUX_DIR(config) @@ -78,21 +78,24 @@ case "${host_os}" in mingw32*) AC_DEFINE_UNQUOTED(MINGW,1,[This is a MinGW system]) AM_CONDITIONAL(MINGW, true) + AM_CONDITIONAL(ADD_RT, false) AC_SUBST([AM_LDFLAGS], ['-Wl,-no-undefined -Wl,--as-needed']) ;; solaris*) LIBS="-lsocket -lnsl -lrt -lxnet" + AM_CONDITIONAL(ADD_RT, true) ;; *-*-darwin*) OPENCL_LIBS="-framework OpenCL" OPENCL_INC="" - AM_CONDITIONAL(OSX, true) + AM_CONDITIONAL(ADD_RT, false) ;; powerpc-*-darwin*) OPENCL_LIBS="" ;; - *) + *) # default + AM_CONDITIONAL(ADD_RT, true) ;; esac diff --git a/opencl/openclwrapper.cpp b/opencl/openclwrapper.cpp index 9f02c353d23b015c956060b238318d57d2837c15..ac1812e39bdf1ed39048805f5c51a1c78baa733f 100644 --- a/opencl/openclwrapper.cpp +++ b/opencl/openclwrapper.cpp @@ -1,4 +1,4 @@ -#ifdef WIN32 +#ifdef _WIN32 #include #include #else