Opened 11 years ago

Last modified 3 years ago

#38168 assigned defect

Conflicting declarations in tiff and opencv

Reported by: karo11 Owned by: mascguy (Christopher Nielsen)
Priority: Normal Milestone:
Component: ports Version: 2.1.3
Keywords: Cc: ryandesign (Ryan Carsten Schmidt), mojca (Mojca Miklavec), cooljeanius (Eric Gallager), MartinBuchmann (Martin Buchmann)
Port: tiff opencv

Description (last modified by larryv (Lawrence Velázquez))

Compiling a program (gmic from gmic.scourceforge.net) using libtiff AND opencv throws errors concerning conflicting declarations. The error occurs since upgrade to MacPorts 2.1.3 :

In file included from /opt/local/include/tiffio.h:33,
                 from ./CImg.h:286,
                 from gmic.h:71,
                 from gmic.cpp:884:
/opt/local/include/tiff.h:77: error: conflicting declaration ‘typedef long int int64’
/opt/local/include/opencv2/core/types_c.h:163: error: ‘int64’ has a previous declaration as ‘typedef int64_t int64’
/opt/local/include/tiff.h:78: error: conflicting declaration ‘typedef long unsigned int uint64’
/opt/local/include/opencv2/core/types_c.h:164: error: ‘uint64’ has a previous declaration as ‘typedef uint64_t uint64’

A workaround would be helpful.

Change History (22)

comment:1 Changed 11 years ago by larryv (Lawrence Velázquez)

Description: modified (diff)
Owner: changed from macports-tickets@… to stromnov@…
Port: & removed

comment:2 Changed 11 years ago by karo11

Hi, I have tried around to overcome this conflicting declaration.

By changing in types_c.h from opencv the lines 163 and 164 to

   typedef long int int64;
   typedef long unsigned int uint64;

the error does not occur anymore.

This would only concern opencv. Is there anybody maintaining this port ?

Last edited 11 years ago by ryandesign (Ryan Carsten Schmidt) (previous) (diff)

comment:3 Changed 11 years ago by stromnov (Andrey Stromnov)

Changing

typedef int64_t int64;
typedef uint64_t uint64;

to

typedef long int int64;
typedef long unsigned int uint64;

is a very bad idea (exceptionally for non-64bit platform).

comment:4 in reply to:  3 Changed 11 years ago by karo11

Replying to stromnov@…:

Changing

typedef int64_t int64;
typedef uint64_t uint64;

to

typedef long int int64;
typedef long unsigned int uint64;

is a very bad idea (exceptionally for non-64bit platform).

Possibly the change in tiffconf.h in the lines or according those lines

/* Signed 64-bit type */
#ifndef __LP64__
#define TIFF_INT64_T signed long long
#else /* __LP64__ */
#define TIFF_INT64_T signed long
#endif /* __LP64__ */

/* Signed 8-bit type */
#define TIFF_INT8_T signed char

/* Unsigned 16-bit type */
#define TIFF_UINT16_T unsigned short

/* Unsigned 32-bit type */
#define TIFF_UINT32_T unsigned int

/* Unsigned 64-bit type */
#ifndef __LP64__
#define TIFF_UINT64_T unsigned long long
#else /* __LP64__ */
#define TIFF_UINT64_T unsigned long
#endif /* __LP64__ */

is better ?

comment:5 Changed 11 years ago by stromnov (Andrey Stromnov)

tiffconf.h constructed at configure phase, so it would be difficult to apply this patch.

Please, attach debug log, I can't reproduce this issue.

comment:6 in reply to:  5 Changed 11 years ago by karo11

Replying to stromnov@…:

tiffconf.h constructed at configure phase, so it would be difficult to apply this patch.

Please, attach debug log, I can't reproduce this issue.

I am trying to build gmic from gmic.sourceforge.net with standard settings plus the opencv camera part: the output of make is perhaps what you mean:

  make -B -j2 "OPT_CFLAGS = -Dcimg_use_opencv `pkg-config opencv --cflags` -fno-tree-pre -ffast-math" "OPT_LDFLAGS= -Dcimg_use_opencv `pkg-config opencv --libs`" macosx

make "CFLAGS=-Dgmic_build -I/opt/local/include -Wall -W -Dgmic_is_beta=1 -Dcimg_display=1 -Dcimg_appname=\\\"gmic\\\" -I/usr/X11R6/include  -Dcimg_use_zlib -Dcimg_use_png -Dcimg_use_jpeg -Dcimg_use_tiff -Dcimg_use_openexr -I/opt/local/include/OpenEXR -Dcimg_use_fftw3  -Dcimg_use_opencv -I/opt/local/include/opencv -I/opt/local/include   -fno-tree-pre -ffast-math" "LDFLAGS=-L/opt/local/lib -lm -L/usr/X11R6/lib -lX11 -lpthread  -lz -lpng -lz -ljpeg -ltiff -lIlmImf -lHalf -lfftw3  -Dcimg_use_opencv /opt/local/lib/libopencv_calib3d.dylib /opt/local/lib/libopencv_contrib.dylib /opt/local/lib/libopencv_core.dylib /opt/local/lib/libopencv_features2d.dylib /opt/local/lib/libopencv_flann.dylib /opt/local/lib/libopencv_gpu.dylib /opt/local/lib/libopencv_highgui.dylib /opt/local/lib/libopencv_imgproc.dylib /opt/local/lib/libopencv_legacy.dylib /opt/local/lib/libopencv_ml.dylib /opt/local/lib/libopencv_nonfree.dylib /opt/local/lib/libopencv_objdetect.dylib /opt/local/lib/libopencv_photo.dylib /opt/local/lib/libopencv_stitching.dylib /opt/local/lib/libopencv_ts.dylib /opt/local/lib/libopencv_video.dylib /opt/local/lib/libopencv_videostab.dylib  " gmic_gmic
g++ -o gmic_bool.o -c gmic.cpp -Dgmic_build -I/opt/local/include -Wall -W -Dgmic_is_beta=1 -Dcimg_display=1 -Dcimg_appname=\"gmic\" -I/usr/X11R6/include  -Dcimg_use_zlib -Dcimg_use_png -Dcimg_use_jpeg -Dcimg_use_tiff -Dcimg_use_openexr -I/opt/local/include/OpenEXR -Dcimg_use_fftw3  -Dcimg_use_opencv -I/opt/local/include/opencv -I/opt/local/include   -fno-tree-pre -ffast-math -Dgmic_split_compilation -Dgmic_bool
g++ -o gmic_uchar.o -c gmic.cpp -Dgmic_build -I/opt/local/include -Wall -W -Dgmic_is_beta=1 -Dcimg_display=1 -Dcimg_appname=\"gmic\" -I/usr/X11R6/include  -Dcimg_use_zlib -Dcimg_use_png -Dcimg_use_jpeg -Dcimg_use_tiff -Dcimg_use_openexr -I/opt/local/include/OpenEXR -Dcimg_use_fftw3  -Dcimg_use_opencv -I/opt/local/include/opencv -I/opt/local/include   -fno-tree-pre -ffast-math -Dgmic_split_compilation -Dgmic_uchar
In file included from /opt/local/include/tiffio.h:33,
                 from ./CImg.h:286,
                 from gmic.h:71,
                 from gmic.cpp:1032:
/opt/local/include/tiff.h:77: error: conflicting declaration ‘typedef long int int64’
/opt/local/include/opencv2/core/types_c.h:163: error: ‘int64’ has a previous declaration as ‘typedef int64_t int64’
/opt/local/include/tiff.h:78: error: conflicting declaration ‘typedef long unsigned int uint64’
/opt/local/include/opencv2/core/types_c.h:164: error: ‘uint64’ has a previous declaration as ‘typedef uint64_t uint64’
In file included from /opt/local/include/tiffio.h:33,
                 from ./CImg.h:286,
                 from gmic.h:71,
                 from gmic.cpp:1032:
/opt/local/include/tiff.h:77: error: conflicting declaration ‘typedef long int int64’
/opt/local/include/opencv2/core/types_c.h:163: error: ‘int64’ has a previous declaration as ‘typedef int64_t int64’
/opt/local/include/tiff.h:78: error: conflicting declaration ‘typedef long unsigned int uint64’
/opt/local/include/opencv2/core/types_c.h:164: error: ‘uint64’ has a previous declaration as ‘typedef uint64_t uint64’
make[1]: *** [gmic_uchar.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: *** [gmic_bool.o] Error 1
make: *** [macosx] Error 2

comment:7 Changed 11 years ago by stromnov (Andrey Stromnov)

Compiling from sources or from macports (sudo port install gmic) ?

comment:8 in reply to:  7 Changed 11 years ago by karo11

Replying to stromnov@…:

Compiling from sources or from macports (sudo port install gmic) ?

Compiling from source, gmic is still not in MacPorts. (It consists of a terminal version and of a Gimp plugin which don't necessitates MacPorts installation).

comment:9 Changed 11 years ago by karo11

By the way the terminal version of gmic could be added to MacPorts, but the Gimp plugin is difficult (at least for me)

comment:10 Changed 11 years ago by devernay (Frédéric Devernay)

The following fix in CImg.h is the most portable solution. Got the idea from the OpenCV source code: https://github.com/Itseez/opencv/commit/33c26a93c6d97013b14e7dd080a347e242ef7f37 Hopefully, David will include this in the next CImg release.

Anyone who wants to include tiff.h or tiffio.h in a portable way should do this.

Index: CImg.h
===================================================================
--- CImg.h	(révision 12475)
+++ CImg.h	(copie de travail)
@@ -284,7 +284,11 @@
 // (see methods 'CImg[List]<T>::{load,save}_tiff()').
 #ifdef cimg_use_tiff
 extern "C" {
+#define uint64 uint64_hack_
+#define int64 int64_hack_
 #include "tiffio.h"
+#undef uint64
+#indef uint64
 }
 #endif

comment:11 Changed 10 years ago by ryandesign (Ryan Carsten Schmidt)

Cc: ryandesign@… added

See also #41280.

comment:12 Changed 10 years ago by mojca (Mojca Miklavec)

Cc: mojca@… added

Cc Me!

comment:13 Changed 10 years ago by cooljeanius (Eric Gallager)

Cc: egall@… added

Cc Me!

comment:14 Changed 10 years ago by mojca (Mojca Miklavec)

Can you please try again? As noted in #41280 I committed a minimal patch in r113360 which might also solve this particular issue.

comment:15 Changed 10 years ago by MartinBuchmann (Martin Buchmann)

Cc: Martin.Buchmann@… added

Cc Me!

comment:16 Changed 8 years ago by ryandesign (Ryan Carsten Schmidt)

Same type of conflict reported between tiff and ocaml in #50737.

comment:17 Changed 3 years ago by mascguy (Christopher Nielsen)

This ticket is no longer relevant, as we don't have an OpenCV 2 port. Can someone close?

comment:18 Changed 3 years ago by ryandesign (Ryan Carsten Schmidt)

The problem doesn't affect opencv (version 3) or opencv4?

The 2013 upsteam tiff issue still exists; see also debate in the rejected 2019 merge request. (The beginning of?) a solution was just merged on January 15, 2021.

comment:19 Changed 3 years ago by mf2k (Frank Schima)

Owner: stromnov deleted
Status: newassigned

comment:20 in reply to:  18 Changed 3 years ago by mascguy (Christopher Nielsen)

Replying to ryandesign:

The problem doesn't affect opencv (version 3) or opencv4?

The 2013 upsteam tiff issue still exists; see also debate in the rejected 2019 merge request. (The beginning of?) a solution was just merged on January 15, 2021.

Ah, I'll take a look. Thanks for the info Ryan!

comment:21 Changed 3 years ago by mascguy (Christopher Nielsen)

Cc: mascguy added

comment:22 Changed 3 years ago by mascguy (Christopher Nielsen)

Cc: mascguy removed
Owner: set to mascguy
Note: See TracTickets for help on using tickets.