As noted elsewhere, I have to force the -m32 option
to build on a 64 bit system, but in addition to that,
I got errors about conflicting C and C++ signatures
for some global variables (this was on a Fedora Core 6
system). The attached patch fixes the problem and seems
to build a working tesseract.
I doubt this is the "right" patch, but it does allow
it to build.
patch to build with gcc 4.1
Logged In: YES
user_id=122014
Originator: NO
Here is the patch needed to compile it for 64 bits architectures (assume C99 compatible compiler):
diff -ruN tesseract-1.02/ccutil/memblk.cpp tesseract-1.02-ef/ccutil/memblk.cpp
--- tesseract-1.02/ccutil/memblk.cpp 2006-06-17 00:17:05.000000000 +0200
+++ tesseract-1.02-ef/ccutil/memblk.cpp 2006-11-23 21:39:11.000000000 +0100
@@ -442,7 +442,7 @@
|| chunk + chunksize - block->blockstart <= 0 || block->blockend - (chunk + chunksize) < 0)
BADMEMCHUNKS.error ("check_mem", ABORT,
"Block=%x, Prev chunk=%x, Chunk=%x, Size=%x",
- (int) block, (int) prevchunk, (int) chunk,
+ (uintptr_t) block, (uintptr_t) prevchunk, (uintptr_t) chunk,
(int) chunk->size);
else if (chunk->size < 0) {
diff -ruN tesseract-1.02/ccutil/memry.cpp tesseract-1.02-ef/ccutil/memry.cpp
--- tesseract-1.02/ccutil/memry.cpp 2006-06-17 00:17:05.000000000 +0200
+++ tesseract-1.02-ef/ccutil/memry.cpp 2006-11-23 21:38:36.000000000 +0100
@@ -124,7 +124,7 @@
DLLSYM void free_string( //free a string
char *string //string to free
) {
- if (((int) string & 3) == 1) { //one over word
+ if (((uintptr_t) string & 3) == 1) { //one over word
string--; //get id marker
if (*string == 0) {
free_mem(string); //generally free it
diff -ruN tesseract-1.02/ccutil/strngs.h tesseract-1.02-ef/ccutil/strngs.h
--- tesseract-1.02/ccutil/strngs.h 2006-06-17 00:17:05.000000000 +0200
+++ tesseract-1.02-ef/ccutil/strngs.h 2006-11-23 21:34:08.000000000 +0100
@@ -21,6 +21,7 @@
#define STRNGS_H
#include <string.h>
+#include <inttypes.h>
#include "memry.h"
#include "serialis.h"
@@ -168,7 +169,7 @@
char *instring; //input from read
INT32 length; //length of string
- instring = (char *) de_serialise_bytes (f, (int) ptr);
+ instring = (char *) de_serialise_bytes (f, (uintptr_t) ptr);
length = (INT32) ptr;
ptr = NULL;
*this = instring;
diff -ruN tesseract-1.02/cutil/structures.h tesseract-1.02-ef/cutil/structures.h
--- tesseract-1.02/cutil/structures.h 2006-06-17 00:17:07.000000000 +0200
+++ tesseract-1.02-ef/cutil/structures.h 2006-11-24 00:33:27.000000000 +0100
@@ -82,7 +82,7 @@
newblock=(char *)memalloc_p(sizeof(type)*blocksize+4); \ if (newblock!=NULL) \ { \ - newblock=(char *)(((int)newblock +4) & (-8)); \ + newblock=(char *)(((uintptr_t)newblock +4) & (-8)); \ } \ element=(type *)newblock; \ } \ @@ -142,7 +142,7 @@
newblock=(char *)memalloc_p(sizeof(type)*blocksize+4);\ if (newblock!=NULL)\ {\ - newblock=(char *)(((int)newblock +4) & (-8));\ + newblock=(char *)(((uintptr_t)newblock +4) & (-8));\ }\ element=(type *)newblock;\ }\
Logged In: YES
user_id=122014
Originator: NO
Grumpf...
Be careful, some \newlines have been inserted in the patch and might be misinterpreted. Typically:
@@ -442,7 +442,7 @@
|| chunk + chunksize - block->blockstart <= 0 || block->blockend
- (chunk + chunksize) < 0)
BADMEMCHUNKS.error ("check_mem", ABORT,
"Block=%x, Prev chunk=%x, Chunk=%x, Size=%x",
- (int) block, (int) prevchunk, (int) chunk,
+ (uintptr_t) block, (uintptr_t) prevchunk, (uintptr_t) chunk,
(int) chunk->size);
The (chunk + chuncksize) is in fact subtracted from the previous line (and not suppressed from the code).
Sorry for that I didn't find the way to upload this patch as a file.