karldergrosse / tesseract-ocr

Automatically exported from code.google.com/p/tesseract-ocr
0 stars 0 forks source link

inconsistent linkage #24

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
http://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg300304.html

Won't build with this as the stopper:

Needless to say, "jam" isn't too happy, either, saying:
[ray@raymondjones tesseract-ocr]$ jam
Jamfile: No such file or directory
...found 7 target(s)...

lassify -I../image -I../dict -I../viewer   -g -O2 -MT tface.o -MD -MP -
MF ".deps/tface.Tpo" -c -o tface.o tface.cpp; \
       then mv -f ".deps/tface.Tpo" ".deps/tface.Po"; else rm -f
".deps/tface.Tpo"; exit 1; fi
../cutil/globals.h:46: error: previous declaration of 'int optind'
with 'C++' linkage
../ccutil/getopt.h:23: error: conflicts with new declaration with 'C'
linkage
../cutil/globals.h:47: error: previous declaration of 'char* optarg'
with 'C++' linkage
../ccutil/getopt.h:24: error: conflicts with new declaration with 'C'
linkage
make[3]: *** [tface.o] Error 1
make[3]: Leaving directory `/home/ray/.src/tesseract-ocr/wordrec'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/ray/.src/tesseract-ocr/wordrec'
make[1]: *** [all-recursive] Error 1

Can someone see what this is about, please?

Bug#409673: FTBFS with GCC 4.2: C/C++ linkage declarations conflict

Martin Michlmayr
Sun, 04 Feb 2007 09:35:06 -0800

Package: tesseract
Version: 1.02-3
Tags: patch

Your package fails to build with recent versions of the gcc-snapshot
package, i.e. a pre-release of GCC 4.2.  The problem is that external
variables are defined both in a C and C++ context, as you can see in
this simple example:

42059:[EMAIL PROTECTED]: ~] /usr/lib/gcc-snapshot/bin/g++ -c t.cc
t.cc:1: error: previous declaration of 'int i' with 'C++' linkage
t.cc:4: error: conflicts with new declaration with 'C' linkage
42060:[EMAIL PROTECTED]: ~] cat t.cc
extern int i;

extern "C" {
        extern int i;
}

According to http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27227#c8 this
is not valid.

A patch is below, although it's possible you could solve this in a
nicer way.  I didn't spend much time on it.

> Automatic build of tesseract_1.02-3 on em64t by sbuild/amd64 0.52
...
>       x86_64-linux-gnu-g++ -DHAVE_CONFIG_H -I. -I. -I..  -I../ccstruct 
> -I../ccutil -I../cutil -I../classify -I../image -I../dict -I../viewer  
-Wall 
> -DTESSDATA_PREFIX=/usr/share/tesseract-ocr/ -DNDEBUG -O2 -Wall -c -o tface.o 
> `test -f 'tface.cpp' || echo './'`tface.cpp
> In file included from /usr/include/unistd.h:783,
>                  from tface.cpp:47:
> ../cutil/globals.h:46: error: previous declaration of 'int optind' with
'C++' 
> linkage
> ../ccutil/getopt.h:23: error: conflicts with new declaration with 'C' linkage
> ../cutil/globals.h:47: error: previous declaration of 'char* optarg' with 
> 'C++' linkage
> ../ccutil/getopt.h:24: error: conflicts with new declaration with 'C' linkage
> make[4]: *** [tface.o] Error 1
> make[4]: Leaving directory `/build/tbm/tesseract-1.02/wordrec'

--- ./cutil/tordvars.h~ 2007-02-04 16:18:12.000000000 +0000
+++ ./cutil/tordvars.h  2007-02-04 16:19:07.000000000 +0000
@@ -39,6 +39,8 @@
 extern FILE *correct_fp;         //correct text
 extern FILE *matcher_fp;

+extern "C"
+{
 extern int blob_skip;            /* Skip to next selection */
 extern int num_word_choices;     /* How many words to keep */
 extern int similarity_enable;    /* Switch for Similarity */
@@ -49,6 +51,7 @@
 extern int show_bold;            /* Use bold text */
 extern int display_text;         /* Show word text */
 extern int display_blocks;       /* Show word as boxes */
+}

 extern float overlap_threshold;  /* Overlap Threshold */
 extern float certainty_threshold;/* When to quit looking */
--- ./cutil/globals.h~  2007-02-04 16:17:07.000000000 +0000
+++ ./cutil/globals.h   2007-02-04 16:17:54.000000000 +0000
@@ -43,9 +43,15 @@
 extern int debugs[MAXPROC];      /*debug flags */
 extern int plots[MAXPROC];       /*plot flags */
 extern int corners[4];           /*corners of scan window */
+#ifdef __cplusplus
+extern "C" {
+#endif
 extern int optind;               /*option index */
 extern char *optarg;             /*option argument */
                                  /*image file name */
+#ifdef __cplusplus
+}
+#endif
 extern char imagefile[FILENAMESIZE];
                                  /* main directory */
 extern char directory[FILENAMESIZE];

-- 
Martin Michlmayr
http://www.cyrius.com/

-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Original issue reported on code.google.com by tmb...@gmail.com on 10 Apr 2007 at 11:48

GoogleCodeExporter commented 9 years ago
I have the same problem when compiling in my Mandriva 2007:1 box. I've added 
the "C"
to the declarations in the following files, after which it compiles:

./cutil/globals.h, line 46:extern "C" int optind;               /*option index 
*/
./cutil/globals.h, line 47:extern "C" char *optarg;             /*option 
argument */
./cutil/tordvars.h, line 48:extern "C" int display_ratings;      /* Show the 
ratings */

Compiler version:
$ g++ --version
g++ (GCC) 4.1.1 20060724 (prerelease) (4.1.1-3mdk)

Original comment by mats.car...@gmail.com on 11 Apr 2007 at 8:20

GoogleCodeExporter commented 9 years ago
Getopt is fixed by reanming the file. This is belt and braces over changing the
#include <getopt.h>, which was a mistake to #include "tessopt.h".
The change to display_ratings breaks the windows build, since it seems to make 
the
definition C++, even with a C declaration.
Can anybody please tell me which system include on your OS declares 
display_ratings
so I can decide whether I really have to rename the variable or I can work 
around the
includes.

Original comment by theraysm...@gmail.com on 17 May 2007 at 7:25

GoogleCodeExporter commented 9 years ago
My system is: 2.6.19-1.2911.6.5.fc6 (Fedora 6)

The previous declaration is happening at tfacep.h:106.

../cutil/tordvars.h:49: error: previous declaration of ‘int 
display_ratings’ with
‘C++’ linkage
tfacep.h:106: error: conflicts with new declaration with ‘C’ linkage

Original comment by rsrip...@gmail.com on 23 May 2007 at 5:23

GoogleCodeExporter commented 9 years ago
see issue #36, which i just submitted

Original comment by z23r...@gmail.com on 16 Jun 2007 at 9:59

GoogleCodeExporter commented 9 years ago
OK, so it wasn't fixed in 1.04, but is properly fixed in v2.0

Original comment by theraysm...@gmail.com on 13 Jul 2007 at 1:49

GoogleCodeExporter commented 9 years ago

Original comment by theraysm...@gmail.com on 18 Jul 2007 at 10:24