cuneiform team mailing list archive
-
cuneiform team
-
Mailing list archive
-
Message #00093
Re: Project status & windows port progress
I have cuneiform working correctly under windows. Here is what I did, hopefully without forgetting anything important.
1. Install MSYS & MinGW
2. Download the MinGW versions of libjpeg, zlib, and libtiff. Untar them but relocate their contents (bin, lib, include directories) to /usrlocal/.
3. Download the current ImageMagick (I used 6.4.4) source and untar in your home directory
4. Build ImageMagick to just use the minimal features needed for Cuneiform; I used the following commands:
export CPPFLAGS=-I/usrlocal/include
export LDFLAGS=-L/usrlocal/lib
./configure --without-perl --without-bzlib --without-dps --without-djvu --without-fpx --without-fontconfig --without-freetype --without-gslib --without-gvc --without-jbig --without-jp2 --without-lcms --without-lqr --without-openexr --without-png --without-rsvg --without-wmf --without-xml --prefix=/c/imagick
5. Compile and install ImageMagick
6. Tell cuneiform cmake how to find ImageMagick:
(export PKG_CONFIG_PATH=/c/imagick/lib/pkgconfig/)
7. Prepare for cuneiform build: create builddir, cd builddir, cmake -G "MSYS Makefiles" ..
8. Update derived makefile: In cuneiform/builddir/cuneiform_src/Kern/CMakeFiles/cuneiform.dir/build.make find "-lMagick++" and add after it "-lMagickCore -lMagickWand". This is because cuneiform cmake is only picking up the Magick++.pc and not the two other required ImageMagick libraries.
9. Apply the patch at the end of this email. The util_spl.cpp change is to read the intermediate file in binary mode so as to prevent the automatic newline behaviors from occuring, and the rling_ma.c change is to take advantage of the automatic newline conversion behavior.
10. Compile and install.
11. Copy the ImageMagick *.dll files from /c/imagick and the *.dll files from /usrlocal/bin (for libjpeg, libtiff, and zlib) to builddir.
12. You should be able to run cuneiform from builddir.
13. For use of the installed version, all the .dll files now present in builddir need to be located with cuneiform.exe or in your path. The /c/imagick installation must be present because it contains configuration files needed to use ImageMagick libraries.
=== modified file 'cuneiform_src/Kern/rfrmt/sources/main/util_spl.cpp'
--- cuneiform_src/Kern/rfrmt/sources/main/util_spl.cpp 2008-09-04 11:32:43 +0000
+++ cuneiform_src/Kern/rfrmt/sources/main/util_spl.cpp 2008-10-23 13:01:42 +0000
@@ -132,9 +132,9 @@
* They are processed as 32-bit integers here, so we need to convert.
*/
-static void readSRECT(SRECT *r, FILE1 *f) {
+static void readSRECT(SRECT *r, FILE *f) {
Rect16 r16;
- fread_m(&r16, sizeof(Rect16), 1, f);
+ fread(&r16, sizeof(Rect16), 1, f);
r->left = r16.left;
r->top = r16.top;
r->right = r16.right;
@@ -450,12 +450,15 @@
short __cdecl OpenFullOutTiger(const char *FileName)
{
- FILE1 *in;
+ FILE *in;
int nc,ns,nw,nz,k_word,k_z,i;
#ifdef alDebug
if(dets) { ConsMess("OpenFullOutTiger Begin "); }
#endif
- if((in=fopen_m(FileName,OF_READ)) == NULL)
+
+ // Open the file in binary mode
+ //if((in=fopen_m(FileName,OF_READ)) == NULL)
+ if((in=fopen(FileName,"rb")) == NULL)
{
#ifdef alDebug
if(dets) { ConsMess("OpenFullOutTiger Internal file -- can not open "); }
@@ -463,11 +466,11 @@
return FALSE;
}
- fread_m(&ScanResolution,sizeof(WORD),1,in);
- fread_m(&NumCol,sizeof(WORD),1,in);
- fread_m(&NumZ,sizeof(WORD),1,in);
- fread_m(&NumW,sizeof(WORD),1,in);
- fread_m(&NumS,sizeof(WORD),1,in);
+ fread(&ScanResolution,sizeof(WORD),1,in);
+ fread(&NumCol,sizeof(WORD),1,in);
+ fread(&NumZ,sizeof(WORD),1,in);
+ fread(&NumW,sizeof(WORD),1,in);
+ fread(&NumS,sizeof(WORD),1,in);
#ifdef alDebug
if(dets) { ConsMess("OpenFullOutTiger ScanResolution=%d ",ScanResolution); }
@@ -477,8 +480,8 @@
if(dets) { ConsMess("OpenFullOutTiger NumS=%d ",NumS); }
#endif
- fread_m(&MonoSpaceAllPage,2,1,in);
- fread_m(&HeiStrAllPage,2,1,in);
+ fread(&MonoSpaceAllPage,2,1,in);
+ fread(&HeiStrAllPage,2,1,in);
Twips = ((float)K_TwipsInInch)/ScanResolution;
// Twips = (float)((int)(Twips+0.5));
@@ -554,11 +557,11 @@
for(nc=0; nc < NumCol; ++nc)
{
- fread_m(&RectFragm[nc],1,sizeof(Rect16),in);
+ fread(&RectFragm[nc],1,sizeof(Rect16),in);
// *********** ÐÀÑ×ÅÒ ÊÎËÎÍÍÎÉ ÑÒÀÒÈÑÒÈÊÈ *************
- fread_m(&NumStr[nc],sizeof(Int16),1,in);
- fread_m(&UserNumber[nc],sizeof(Word32),1,in);
- fread_m(&FragFlag[nc],sizeof(Word32),1,in);
+ fread(&NumStr[nc],sizeof(Int16),1,in);
+ fread(&UserNumber[nc],sizeof(Word32),1,in);
+ fread(&FragFlag[nc],sizeof(Word32),1,in);
Zn[nc]=(ZN***)Submalloc((NumStr[nc])*sizeof(ZN**),&SubZn);
TitleStr[nc]=(TITLE_STR*)Submalloc((NumStr[nc])*sizeof(TITLE_STR),&SubZn);
@@ -584,10 +587,10 @@
//Ðåàëüíûå êîîð. ñòðîêè!
//fread_m(&t->S_Real_Rect,sizeof(SRECT),1,in);
readSRECT(&t->S_Real_Rect, in);
- fread_m(&tmp,2,1,in);
+ fread(&tmp,2,1,in);
t->S_Gen.S_NumWord = tmp; // NumWrd
- fread_m(&t->S_Flags,sizeof(t->S_Flags),1,in); //NEGA_STR
+ fread(&t->S_Flags,sizeof(t->S_Flags),1,in); //NEGA_STR
t->S_Gen.HeadLine = 0; // zero HeadLine
k_word = TitleStr[nc][ns].S_Gen.S_NumWord-1;
@@ -601,14 +604,14 @@
TITLE_WORD *tw=&TitleWord[nc][ns][nw];
tw->Z_Code=1;
- fread_m(&tmp, sizeof(Int16), 1, in);
+ fread(&tmp, sizeof(Int16), 1, in);
tw->W_Gen.W_NumSym=tmp;// NumZn
k_z=tw->W_Gen.W_NumSym-1;
- fread_m(&tmp, sizeof(Int16), 1, in);
+ fread(&tmp, sizeof(Int16), 1, in);
tw->W_Gen.FontNumber=(WORD)tmp;
- fread_m(&tmp, sizeof(Int16), 1, in);
+ fread(&tmp, sizeof(Int16), 1, in);
tw->W_Gen.FontSize=(WORD)tmp;
if((Zn[nc][ns][nw]=(ZN*)Submalloc((k_z+1)*sizeof(ZN),&SubZn))==NULL)
@@ -630,7 +633,7 @@
//fread_m(&tz->Z_RealRect,sizeof(SRECT),1,in); // Real BOX
readSRECT(&tz->Z_RealRect, in);
- fread_m(&num, sizeof(Int16), 1, in); tz->Z_Num_Alt=(BYTE)MIN(num,REC_MAX_VERS); //NumAlt
+ fread(&num, sizeof(Int16), 1, in); tz->Z_Num_Alt=(BYTE)MIN(num,REC_MAX_VERS); //NumAlt
// if(num > 1)
// num = 1;
@@ -641,7 +644,7 @@
tz->Z_Id.word = 0;
for ( i = 0; i < num; i++ )
{
- fread_m(&alt1,sizeof(struct ALT_TIGER1),1,in);
+ fread(&alt1,sizeof(struct ALT_TIGER1),1,in);
if(i < REC_MAX_VERS)
{
ALT_ZN *Alt =&z->Alt[i];
@@ -650,7 +653,7 @@
Alt->a_Dist=(float)(alt1.prob/256.);
}
}
- fread_m(&alt2,sizeof(struct ALT_TIGER2),1,in);
+ fread(&alt2,sizeof(struct ALT_TIGER2),1,in);
for ( i=0; i<tz->Z_Num_Alt;i++)
{
ALT_ZN *Alt =&z->Alt[i];
@@ -664,14 +667,14 @@
}
}
}
- fclose_m(in);
+ fclose(in);
--NumCol;
#ifdef alDebug
if(dets) { ConsMess("OpenFullOutTiger End"); }
#endif
return TRUE;
BadReturn:
- fclose_m(in);
+ fclose(in);
#ifdef alDebug
if(dets) { ConsMess("OpenFullOutTiger End"); }
#endif
=== modified file 'cuneiform_src/Kern/rling/sources/c/rling_ma.c'
--- cuneiform_src/Kern/rling/sources/c/rling_ma.c 2008-07-31 12:15:01 +0000
+++ cuneiform_src/Kern/rling/sources/c/rling_ma.c 2008-10-23 14:00:22 +0000
@@ -401,6 +401,13 @@
break;
} /* EOF */
+ /* MinGW file io seems to turn windows file endings into \n
+ so break -- no skip as when the \r is passed through */
+
+ if ( ch == '\n' ) {
+ break;
+ }
+
if ( ch == '\r' ) /* JussiP: The data files have Windows line endings. */
{
TE_read(Handle, &ch, 1L); /* Skip the following \n. */
Follow ups
References