vtk9.3.0 mingw multiple definition of `vtktiff__TIFFBuiltinCODECS'

In file included from E:/ ode2023E:\code20231018\parallel\VTK-9.3.0\ThirdParty\hdf5\vtkhdf5\src\H5Gint.c:341 18/parallel/VTK-9.3.0/ThirdPa:
rt /tiff/vtE:\code20231018\parallel\VTK-9.3.0\ThirdParty\hdf5\vtkhdf5\src\H5Gint.c:kt ff/libtiff/tiffi In function 'op h:vtkhdf5_H5G_nameof4 6':
:  ultiple definition of `E:\code20231018\parallel\VTK-9.3.0\ThirdParty\hdf5\vtkhdf5\src\H5Gint.c:697:41:v ktiff__TIFFerrorHandlerExt ';warning:  CMakeFiles\tiff.dir/objects.a(tif_aux.c.obj)return discards ':E:/codeconst2 231018/parallel/VTK-9' qualifier from pointer target type [. .0/ThirdParty/tiff/vtktiff/libtiff/tif-Wdiscarded-qualifiersfi p.]
  697 |     FUNC_LEAVE_NOAPI(grp ? &(grp->path) : NULL)
h:4E:\code20231018\parallel\VTK-9.3.0\ThirdParty\hdf5\vtkhdf5\src\H5private.h:2473:13:2  : firsnote: t  efined herein definition of macro '
D:/QtFUNC_LEAVE_NOAPI/T ol'
 2473 |     return (s/ ingw112ret_value0_ 4/bin/../lib/g);                                                                                      \
      |             cc/ 86_64-w64-mingw32/1^~~~~~~~~1 2.0/
../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\tiff.dir/objects.a(tif_read.c.obj):E:/code20231018/parallel/VTK-9.3.0/ThirdParty/tiff/vtktiff/libtiff/tiffiop.h:511: multiple definition of `vtktiff__TIFFBuiltinCODECS'; CMakeFiles\tiff.dir/objects.a(tif_aux.c.obj):E:/code20231018/parallel/VTK-9.3.0/ThirdParty/tiff/vtktiff/libtiff/tiffi[ 23%] op.h:Generating the wrap hierarchy for VTK::ViewsContext2D511
: first defined here
D:/Qt/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\tiff.dir/objects.a(tif_strip.c.obj):E:/code20231018/parallel/VTK-9.3.0/ThirdParty/tiff/vtktiff/libtiff/tiffiop.h:423: multiple definition of `vtktiff__TIFFwarningHandler'; CMakeFiles\tiff.dir/objects.a(tif_aux.c.obj):E:/code20231018/parallel/VTK-9.3.0/ThirdParty/tiff/vtktiff/libtiff/tiffiop.h:423: first defined here
D:/Qt/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\tiff.dir/objects.a(tif_strip.c.obj):E:/code20231018/parallel/VTK-9.3.0/ThirdParty/tiff/vtktiff/libtiff/tiffiop.h:424: multiple definition of `vtktiff__TIFFerrorHandler'; CMakeFiles\tiff.dir/objects.a(tif_aux.c.obj):E:/code20231018/parallel/VTK-9.3.0/ThirdParty/tiff/vtktiff/libtiff/tiffiop.h:424: first defined here
D:/Qt/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\tiff.dir/objects.a(tif_strip.c.obj):E:/code20231018/parallel/VTK-9.3.0/ThirdParty/tiff/vtktiff/libtiff/tiffiop.h:425: multiple definition of `vtktiff__TIFFwarningHandlerExt'; CMakeFiles\tiff.dir/objects.a(tif_aux.c.obj):E:/code20231018/parallel/VTK-9.3.0/ThirdParty/tiff/vtktiff/libtiff/tiffiop.h:425: first defined here
D:/Qt/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\tiff.dir/objects.a(tif_strip.c.obj):E:/code20231018/parallel/VTK-9.3.0/ThirdParty/tiff/vtktiff/libtiff/tiffiop.h:426: multiple definition of `vtktiff__TIFFerrorHandlerExt'; CMakeFiles\tiff.dir/objects.a(tif_aux.c.obj):E:/code20231018/parallel/VTK-9.3.0/ThirdParty/tiff/vtktiff/libtiff/tiffiop.h:426: first defined here
D:/Qt/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\tiff.dir/objects.a(tif_strip.c.obj):E:/code20231018/parallel/VTK-9.3.0/ThirdParty/tiff/vtktiff/libtiff/tiffiop.h:511: multiple definition of `vtktiff__TIFFBuiltinCODECS'; CMakeFiles\tiff.dir/objects.a(tif_aux.c.obj):E:/code20231018/parallel/VTK-9.3.0/ThirdParty/tiff/vtktiff/libtiff/tiffiop.h:511: first defined here
D:/Qt/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\tiff.dir/objects.a(tif_swab.c.obj):E:/code20231018/parallel/VTK-9.3.0/ThirdParty/tiff/vtktiff/libtiff/tiffiop.h:[ 23%] 423Building C object ThirdParty/hdf5/vtkhdf5/src/CMakeFiles/vtkhdf5_src.dir/H5Gname.c.obj:
 multiple definition of `vtktiff__TIFFwarningHandler';[ 24%]  Building CXX object Common/Core/CMakeFiles/CommonCore.dir/vtkAnimationCue.cxx.objCMakeFiles\tiff.dir/objects.a(tif_aux.c.obj)
:E:/code20231018/parallel/VTK-9.3.0/ThirdParty/tiff/vtktiff/libtiff/tiffiop.h:423:[ 24%]  first defined hereGenerating the wrap hierarchy for VTK::IOExportGL2PS

D:/Qt/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\tiff.dir/objects.a(tif_swab.c.obj):E:/code20231018/parallel/VTK-9.3.0/ThirdParty/tiff/vtktiff/libtiff/tiffiop.h:424: multiple definition of `vtktiff__TIFFerrorHandler'; CMakeFiles\tiff.dir/objects.a(tif_aux.c.obj):E:/code20231018/parallel/VTK-9.3.0/ThirdParty/tiff/vtktiff/libtiff/tiffiop.h:424: first defined here
D:/Qt/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\tiff.dir/objects.a(tif_swab.c.obj):E:/code20231018/parallel/VTK-9.3.0/ThirdParty/tiff/vtktiff/libtiff/tiffiop.h:425: multiple definition of `vtktiff__TIFFwarningHandlerExt'; CMakeFiles\tiff.dir/objects.a(tif_aux.c.obj):E:/code20231018/parallel/VTK-9.3.0/ThirdParty/tiff/vtktiff/libtiff/tiffiop.h:425: first defined here
D:/Qt/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\tiff.dir/objects.a(tif_swab.c.obj):E:/code20231018/parallel/VTK-9.3.0/ThirdParty/tiff/vtktiff/libtiff/tiffiop.h:426: multiple definition of `vtktiff__TIFFerrorHandlerExt'; CMakeFiles\tiff.dir/objects.a(tif_aux.c.obj):E:/code20231018/parallel/VTK-9.3.0/ThirdParty/tiff/vtktiff/libtiff/tiffiop.h:426: first defined here
D:/Qt/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\tiff.dir/objects.a(tif_swab.c.obj):E:/code20231018/parallel/VTK-9.3.0/ThirdParty/tiff/vtktiff/libtiff/tiffiop.h:511: multiple definition of `vtktiff__TIFFBuiltinCODECS'; CMakeFiles\tiff.dir/objects.a(tif_aux.c.obj):E:/code20231018/parallel/VTK-9.3.0/ThirdParty/tiff/vtktiff/libtiff/tiffiop.h:511: first defined here
D:/Qt/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\tiff.dir/objects.a(tif_thunder.c.obj):E:/code20231018/parallel/VTK-9.3.0/ThirdParty/tiff/vtktiff/libtiff/tiffiop.h:423: multiple definition of `vtktiff__TIFFwarningHandler'; CMakeFiles\tiff.dir/objects.a(tif_aux.c.obj):E:/code20231018/parallel/VTK-9.3.0/ThirdParty/tiff/vtktiff/libtiff/tiffiop.h:423: first defined here
D:/Qt/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\tiff.dir/objects.a(tif_thunder.c.obj):E:/code20231018/parallel/VTK-9.3.0/ThirdParty/tiff/vtktiff/libtiff/tiffiop.h:424: multiple definition of `vtktiff__TIFFerrorHandler'; CMakeFiles\tiff.dir/objects.a(tif_aux.c.obj):E:/code20231018/parallel/VTK-9.3.0/ThirdParty/tiff/vtktiff/libtiff/tiffiop.h:424: first defined here
D:/Qt/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\tiff.dir/objects.a(tif_thunder.c.obj):E:/code20231018/parallel/VTK-9.3.0/ThirdParty/tiff/vtktiff/libtiff/tiffiop.h:425: multiple definition of `vtktiff__TIFFwarningHandlerExt'; CMakeFiles\tiff.dir/objects.a(tif_aux.c.obj):E:/code20231018/parallel/VTK-9.3.0/ThirdParty/tiff/vtktiff/libtiff/tiffiop.h:425: first defined here
D:/Qt/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFile[ 24%] s\tiff.dir/objBuilt target vtkViewsContext2D-hierarchy
ects.a(tif_thunder.c.obj):E:/code20231018/parallel/VTK-9.3.0/ThirdParty/tiff/vtktiff/libtiff/tiffiop.h:426: multiple definition of `vtktiff__TIFFerrorHandlerExt'; CMakeFiles\tiff.dir/objects.a(tif_aux.c.obj):E:/code20231018/parallel/VTK-9.3.0/ThirdParty/tiff/vtktiff/libtiff/tiffiop.h:426: first defined here
D:/Qt/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\tiff.dir/objects.a(tif[ 24%] _thunder.c.obj)Building CXX object ThirdParty/libproj/vtklibproj/src/CMakeFiles/libproj.dir/projections/goode.cpp.obj
:E:/code20231018/parallel/VTK-9.3.0/ThirdParty/tiff/vtktiff/libtiff/tiffiop.h:511: multiple definition of `vtktiff__TIFFBuiltinCODECS'; CMakeFiles\tiff.dir/objects[ 24%] .a(tif_aux.c.obj)Building C object ThirdParty/hdf5/vtkhdf5/src/CMakeFiles/vtkhdf5_src.dir/H5Gnode.c.obj:
E:/code20231018/parallel/VTK-9.3.0/ThirdParty/tiff/vtktiff/libtiff/tiffiop.h:511: first defined here
D:/Qt/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\tiff.dir/objects.a(tif_tile.c.obj):E:/code20231018/parallel/VTK-9.3.0/ThirdParty/tiff/vtktiff/libtiff/tiffiop.h:423: multiple definition of `vtktiff__TIFFwarningHandler'; CMakeFiles\tiff.dir/objects.a(tif_aux.c.obj):E:/code20231018/parallel/VTK-9.3.0/ThirdParty/tiff/vtktiff/libtiff/tiffiop.h:423: first defined here
D:/Qt/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\tiff.dir/objects.a(tif_tile[ 24%] .c.obj)Building CXX object Common/Core/CMakeFiles/CommonCore.dir/vtkArchiver.cxx.obj:
E:/code20231018/parallel/VTK-9.3.0/ThirdParty/tiff/vtktiff/libtiff/tiffiop.h:424: multiple definition of `vtktiff__TIFFerrorHandler'; CMakeFiles\tiff.dir/objects.a(tif_aux.c.obj):E:/code20231018/parallel/VTK-9.3.0/ThirdParty/tiff/vtktiff/libtiff/tiffiop.h:424: first defined here
D:/Qt/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\tiff.dir/objects.a(tif_tile.c.obj):E:/code20231018/parallel/VTK-9.3.0/ThirdParty/tiff/vtktiff/libtiff/tiffiop.h:425: multiple definition of `vtktiff__TIFFwarningHandlerExt'; CMakeFiles\tiff.dir/objects.a(tif_aux.c.obj):E:/code20231018/parallel/VTK-9.3.0/ThirdParty/tiff/vtktiff/libtiff/tiffiop.h:425: first defined here
D:/Qt/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\tiff.dir/objects.a(tif_tile.c.obj):E:/code20231018/parallel/VTK-9.3.0/ThirdParty/tiff/vtktiff/libtiff/tiffiop.h:426: multiple definition of `vtktiff__TIFFerrorHandlerExt'; CMakeFiles\tiff.dir/objects.a(tif_aux.c.obj):E:/code20231018/parallel/VTK-9.3.0/ThirdParty/tiff/vtktiff/libtiff/tiffiop.h:426: first defined here
D:/Qt/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\tiff.dir/objects.a(tif_tile.c.obj):E:/code20231018/parallel/VTK-9.3.0/ThirdParty/tiff/vtktiff/libtiff/tiffiop.h:511: multiple definition of `vtktiff__TIFFBuiltinCODECS'; CMakeFiles\tiff.dir/objects.a(tif_aux.c.obj):E:/code20231018/parallel/VTK-9.3.0/ThirdParty/tiff/vtktiff/libtiff/tiffiop.h:511: first defined here
D:/Qt/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\tiff.dir/objects.a(tif_version.c.obj):E:/code20231018/parallel/VTK-9.3.0/ThirdParty/tiff/vtktiff/libtiff/tiffiop.h:423: multiple definition of `vtktiff__TIFFwarningHandler'; CMakeFiles\tiff.dir/objects.a(tif_aux.c.obj):E:/code20231018/parallel/VTK-9.3.0/ThirdParty/tiff/vtktiff/libtiff/tiffiop.h:423: first defined here
D:/Qt/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\tiff.dir/objects.a(tif_version.c.obj):E:/code20231018/parallel/VTK-9.3.0/ThirdParty/tiff/vtktiff/libtiff/tiffiop.h:424: multiple definition of `vtktiff__TIFFerrorHandler'; CMakeFiles\tiff.dir/objects.a(tif_aux.c.obj):E:/code20231018/parallel/VTK-9.3.0/ThirdParty/tiff/vtktiff/libtiff/tiffiop.h:424: first defined here
D:/Qt/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\tiff.dir/objects.a(tif_version.c.obj):E:/code20231018/parallel/VTK-9.3.0/ThirdParty/tiff/vtktiff/libtiff/tiffiop.h:425: multiple definition of `vtktiff__TIFFwarningHandlerExt'; CMakeFiles\tiff.dir/

What is your build system?

I got the same errors using cmake and ninja under msys2/mingw64 on Windows 10. The problem shows up due to a change in the default handling of identically-defined items used in header files.

The fix is to add the option

 -fcommon

to your compile commands. In my case I added the following to line 9 of my CMakeLists.txt

 line 9:    add_compile_options(-Os -O3 -fcommon)

The -Os and -O3 fix a file-too-large error by optimizing for size. The -fcommon fixes the multiple definitions error. Note that the approach used in VTK header files is no longer considered the proper way to declare variables/functions because each time the header file is included a new – identical – definition of the variable/function is created.

Note that header files should never create code or instantiate variables or functions because including the headers in more than one source creates multiple declarations. Use of “extern” is the proper prefix for things you want to define in headers for access by multiple source files. Use of “inline” definitions is OK because the compiler creates a local copy of the inline function at each place it is used rather than creating a stand-alone instance of the function.

Right now my build is still hung during the link phase because a template does not appear to be getting instantiated by the compiler, so the linker throws an undefined-reference error during the ninja build.

Hoping the -fcommon helps with your build.

This isn’t an actual fix. It’s more like a workaround. The error is caused by ill-written libtiff code (apparently missing external declarations) that apparently still doesn’t refelect the recent change in GCC (or GCC-like compilers like MinGW’s) behavior: Project:Toolchain/Gcc 10 porting notes/fno common - Gentoo wiki . If that was fixed in libtiff, then VTK developers should update its third party code.

regards,

PC

Changing VTK’s CMakeLists.txt is not the best practice. Just add -fcommon to the compiler flags in CMAKE_CXX_FLAGS and CMAKE_C_FLAGS CMake variables during configuration. E.g.: run the comand cmake ... -DCMAKE_CXX_FLAGS=-fcommon -DCMAKE_C_FLAGS=-fcommon ....

best,

PC

1 Like