InsightSoftwareConsortium / ITK

Insight Toolkit (ITK) -- Official Repository. ITK builds on a proven, spatially-oriented architecture for processing, segmentation, and registration of scientific images in two, three, or more dimensions.
https://itk.org
Apache License 2.0
1.42k stars 664 forks source link

HDF5 error about including private headers H5Tpkg.h #509

Open phcerdan opened 5 years ago

phcerdan commented 5 years ago

Raised by @lorensen in discourse https://discourse.itk.org/t/gcc-8-2/1601/2 and reproduced locally with gcc8.2.

build log: https://open.cdash.org/viewBuildError.php?buildid=5754102

Might be related to latest hdf5 update?

Building C object Modules/ThirdParty/HDF5/src/itkhdf5/src/CMakeFiles/hdf5-shared.dir/__/shared/H5Tinit.c.o
FAILED: Modules/ThirdParty/HDF5/src/itkhdf5/src/CMakeFiles/hdf5-shared.dir/__/shared/H5Tinit.c.o
/usr/lib/colorgcc/bin/cc -DH5_BUILT_AS_DYNAMIC_LIB -DH5_BUILT_AS_DYNAMIC_LIB=1 -DNDEBUG -D_GNU_SOURCE -Dhdf5_shared_EXPORTS -IModules/ThirdParty/ZLIB/src -IModules/ThirdParty/ZLIB/src -IModules/ThirdParty/HDF5/src -IModules/ThirdParty/HDF5/src -IModules/ThirdParty/HDF5/src/itkhdf5/src -IModules/ThirdParty/HDF5/src/itkhdf5 -Wno-uninitialized -Wno-unused-parameter -Wall -Wcast-align -Wdisabled-optimization -Wextra -Wformat=2 -Winvalid-pch -Wno-format-nonliteral -Wpointer-arith -Wshadow -Wunused -Wwrite-strings -funit-at-a-time -Wno-strict-overflow  -w -std=c99 -fstdarg-opt -pedantic -Wall -Wextra -fmessage-length=0 -O2 -g -DNDEBUG -fPIC -MD -MT Modules/ThirdParty/HDF5/src/itkhdf5/src/CMakeFiles/hdf5-shared.dir/__/shared/H5Tinit.c.o -MF Modules/ThirdParty/HDF5/src/itkhdf5/src/CMakeFiles/hdf5-shared.dir/__/shared/H5Tinit.c.o.d -o Modules/ThirdParty/HDF5/src/itkhdf5/src/CMakeFiles/hdf5-shared.dir/__/shared/H5Tinit.c.o   -c Modules/ThirdParty/HDF5/src/itkhdf5/shared/H5Tinit.c
In file included from Modules/ThirdParty/HDF5/src/itkhdf5/shared/H5Tinit.c:82:
Modules/ThirdParty/HDF5/src/itkhdf5/src/H5Tpkg.h:23:2: error: #error "Do not include this file outside the H5T package!"
 #error "Do not include this file outside the H5T package!"
thewtex commented 5 years ago

This is likely related to the recent HDF5 update:

https://github.com/InsightSoftwareConsortium/ITK/pull/397

It now showing up on the dashboard thanks to @lorensen 's build:

https://open.cdash.org/viewBuildError.php?buildid=5756101

I will take a look.

thewtex commented 5 years ago

@phcerdan @lorensen I addressed these issues with the gcc:8 Docker image compiler: https://github.com/InsightSoftwareConsortium/ITK/pull/510

but I did not experience that error. What CMake version are you using? Are there any other CMake options passed?

phcerdan commented 5 years ago

I am using latest CMake, and I am sure both of us have the ITKVtkGlue module enabled. I will be able to have a look next week if the docker image doesn't reproduce it.

phcerdan commented 5 years ago

I have tested it with ITKVtkGlue OFF and ON, BUILD_SHARED_LIBS OFF or ON, and same results.

The error is the same than the one reported in vcpkg: https://github.com/Microsoft/vcpkg/issues/3867 and might be related with the hdf5 CMakeFiles.txt problem related to find_package. Pinging @dzenanz, as he references the same issue in other PR in vcpkg. Even though there reported that was solved not using SYSTEM_HDF5, but here it fails compiling HDF5 internally.

phcerdan commented 5 years ago

My CMake version is 3.13.4-1

phcerdan commented 5 years ago

Ok, clean build with default CMake options (disabling tests) works good! This is, no ITKVtkGlue, no CMAKE_BUILD_SHARED.

I will try to isolate the error enabling those options. I don't think this is related to gcc8

phcerdan commented 5 years ago

Enabling ITKVtkGlue with system VTK (this is system vtk-8.2.0-1 with system hdf5-1.10.4-1) fails with error: Note that targets are cleaned before rebuilding with: ninja -t clean hdf5-static hdf5_cpp-static

Error:


[352/354] Building C object Modules/ThirdParty/HDF5/src/itkhdf5/src/CMakeFiles/hdf5-static.dir/__/H5Tinit.c.o
FAILED: Modules/ThirdParty/HDF5/src/itkhdf5/src/CMakeFiles/hdf5-static.dir/__/H5Tinit.c.o
/usr/lib/colorgcc/bin/cc -DNDEBUG -D_GNU_SOURCE -IModules/ThirdParty/ZLIB/src -I/Modules/ThirdParty/ZLIB/src -I/Modules/ThirdParty/HDF5/src -IModules/ThirdParty/HDF5/src -I/Modules/ThirdParty/HDF5/src/itkhdf5/src -IModules/ThirdParty/HDF5/src/itkhdf5 -Wno-uninitialized -Wno-unused-parameter -Wall -Wcast-align -Wdisabled-optimization -Wextra -Wformat=2 -Winvalid-pch -Wno-format-nonliteral -Wpointer-arith -Wshadow -Wunused -Wwrite-strings -funit-at-a-time -Wno-strict-overflow  -w -std=c99 -fstdarg-opt -pedantic -Wall -Wextra -fmessage-length=0 -O3 -DNDEBUG -fPIC -MD -MT Modules/ThirdParty/HDF5/src/itkhdf5/src/CMakeFiles/hdf5-static.dir/__/H5Tinit.c.o -MF Modules/ThirdParty/HDF5/src/itkhdf5/src/CMakeFiles/hdf5-static.dir/__/H5Tinit.c.o.d -o Modules/ThirdParty/HDF5/src/itkhdf5/src/CMakeFiles/hdf5-static.dir/__/H5Tinit.c.o   -c Modules/ThirdParty/HDF5/src/itkhdf5/H5Tinit.c
cc: error: Modules/ThirdParty/HDF5/src/itkhdf5/H5Tinit.c: No such file or directory
cc: fatal error: no input files
compilation terminated.
ninja: build stopped: subcommand failed.
phcerdan commented 5 years ago

Using non-system VTK but VTK_DIR=/path-VTK 8.1.1/build works.

I guess there must be some clashing between HDF5 in ITK and the one used in VTK, at least when VTK uses system HDF5...

The thing I should double check is what happens when instead of system VTK-8.2.0-1 using system HDF5 (the one failing), I build the same version of VTK using their internal HDF5.

phcerdan commented 5 years ago

Tested with my compiled vtk-8.2.0 using their internal hdf5 and no problems. I guess it can be narrowed down to problems using system hdf5 in VTK and non-system hdf5 in ITK...

thewtex commented 5 years ago

Great deduction @phcerdan :eye:

system hdf5 in VTK and non-system hdf5 in ITK

This may be difficult to support versus 'system / system' and 'non-system / non-system'. Does VTKConfig.cmake provide information on whether VTK was built with a system HDF5? We could at least, then, throw an error when it is know to cause an issue.

revolvet commented 5 years ago

Is this issue fixed? I still having this problem, and can't build any project dependent on this library. Thanks!

thewtex commented 5 years ago

@revolvet are you also building with VTK? Is HDF5 system in both cases or non-system in both cases?

revolvet commented 5 years ago

@revolvet are you also building with VTK? Is HDF5 system in both cases or non-system in both cases?

I didn't enable itkvtkglue. Now it works when itkvtkglue is enabled, although itkvtkglue itself fails because of something wrong with vtkOStreamWrapper.h. Thanks!

chenray844 commented 5 years ago

When I build Slicer https://github.com/Slicer/Slicer that is dependent on VTK and ITK, I meet this bug too.

In file included from /home/chenrf/Projects/medical/slicer/build/ITK-build/Modules/ThirdParty/HDF5/src/itkhdf5/shared/H5Tinit.c:82:0:
/home/chenrf/Projects/medical/slicer/build/ITK/Modules/ThirdParty/HDF5/src/itkhdf5/src/H5Tpkg.h:23:2: error: #error "Do not include this file outside the H5T package!"
 #error "Do not include this file outside the H5T package!"
  ^~~~~
Modules/ThirdParty/HDF5/src/itkhdf5/src/CMakeFiles/hdf5-shared.dir/build.make:3944: recipe for target 'Modules/ThirdParty/HDF5/src/itkhdf5/src/CMakeFiles/hdf5-shared.dir/__/shared/H5Tinit.c.o' failed
make[5]: *** [Modules/ThirdParty/HDF5/src/itkhdf5/src/CMakeFiles/hdf5-shared.dir/__/shared/H5Tinit.c.o] Error 1
CMakeFiles/Makefile2:6965: recipe for target 'Modules/ThirdParty/HDF5/src/itkhdf5/src/CMakeFiles/hdf5-shared.dir/all' failed
make[4]: *** [Modules/ThirdParty/HDF5/src/itkhdf5/src/CMakeFiles/hdf5-shared.dir/all] Error 2
make[4]: *** Waiting for unfinished jobs....

How can I fix this bug?

Thanks.

phcerdan commented 5 years ago

@chenray844 I would suggest you raise the issue in Slicer, linking to this issue in your report. There, please report the version of Slicer you are building, and the CMake options, so it can be reproduced.

The problems seem to arise when mixing system/non-system HDF5 between VTK and ITK.

are you also building with VTK? Is HDF5 system in both cases or non-system in both cases?

chenray844 commented 5 years ago

Thanks.

I build VTK and ITK with non-sysem in both cases.

I will raise the issue in Slicer later. thanks .

dzenanz commented 5 years ago

A possibly related issue arising with VTK including GLEW: https://github.com/microsoft/vcpkg/issues/7519#issuecomment-524233329

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions.

dzenanz commented 4 years ago

@N-Dekker @blowekamp @phcerdan I thought something was done about this recently? Or maybe it was something similar?

phcerdan commented 4 years ago

Missing context here, I would think this can be marked safely as stale?

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions.