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.43k stars 666 forks source link

IBM powerpc compile error #1960

Closed Mon-ius closed 4 years ago

Mon-ius commented 4 years ago

Hi, I am working on Power9 with ppcle-64 arch. I tried to compile it. It shows error.

Scanning dependencies of target ITKReview-all
[100%] Built target ITKReview-all
[100%] Linking CXX static library ../../../../lib/libITKTestKernel-5.1.a
[100%] Built target ITKTestKernel
Scanning dependencies of target itkTestDriver
[100%] Building CXX object Modules/Core/TestKernel/src/CMakeFiles/itkTestDriver.dir/itkTestDriver.cxx.o
[100%] Linking CXX executable ../../../../bin/itkTestDriver
../../../../lib/libitkpng-5.1.a(pngrutil.c.o):pngrutil.c:function itk_png_read_filter_row: error: undefined reference to 'png_init_filter_functions_vsx'
collect2: error: ld returned 1 exit status
make[5]: *** [bin/itkTestDriver] Error 1
make[4]: *** [Modules/Core/TestKernel/src/CMakeFiles/itkTestDriver.dir/all] Error 2
make[3]: *** [all] Error 2
make[2]: *** [ITKv5-prefix/src/ITKv5-stamp/ITKv5-build] Error 2
make[1]: *** [CMakeFiles/ITKv5.dir/all] Error 2
make: *** [all] Error 2
dzenanz commented 4 years ago

Does updating the bundled PNG version help? I suspect that platform-specific optimizations in libPNG are the cause.

Mon-ius commented 4 years ago

How to Using the UpdateFromUpstream.sh script? I didn't find it.

dzenanz commented 4 years ago

https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/ThirdParty/PNG/UpdateFromUpstream.sh

Mon-ius commented 4 years ago

I tried to replace the file from https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK/4bdc38ca9bedac7c2c61e29f014e902e1fe6a2e7/Modules/ThirdParty/PNG/src/itkpng/pngrutil.c, and still error.

../../../../lib/libitkpng-5.2.a(pngrutil.c.o):pngrutil.c:function itk_png_read_filter_row: error: undefined reference to 'png_init_filter_functions_vsx'

How to use your script? UpdateFromUpstream.sh after git clone https://github.com/InsightSoftwareConsortium/ITK.git? Run it under project root or under ./Modules/ThirdParty/PNG/

Mon-ius commented 4 years ago

I tried to run the UpdateFromUpstream.sh under the project root folder.

./Modules/ThirdParty/PNG/UpdateFromUpstream.sh

And get these.


fatal: cannot use Perl-compatible regexes when not compiled with USE_LIBPCRE
Created upstream snapshot branch 'upstream-png'.
error: Your local changes to the following files would be overwritten by merge:
    Modules/ThirdParty/PNG/src/itkpng/LICENSE
    Modules/ThirdParty/PNG/src/itkpng/png.c
    Modules/ThirdParty/PNG/src/itkpng/png.h
    Modules/ThirdParty/PNG/src/itkpng/pngconf.h
    Modules/ThirdParty/PNG/src/itkpng/pngdebug.h
    Modules/ThirdParty/PNG/src/itkpng/pngerror.c
    Modules/ThirdParty/PNG/src/itkpng/pngget.c
    Modules/ThirdParty/PNG/src/itkpng/pnginfo.h
    Modules/ThirdParty/PNG/src/itkpng/pngmem.c
    Modules/ThirdParty/PNG/src/itkpng/pngpread.c
    Modules/ThirdParty/PNG/src/itkpng/pngpriv.h
    Modules/ThirdParty/PNG/src/itkpng/pngread.c
    Modules/ThirdParty/PNG/src/itkpng/pngrio.c
    Modules/ThirdParty/PNG/src/itkpng/pngrtran.c
    Modules/ThirdParty/PNG/src/itkpng/pngrutil.c
    Modules/ThirdParty/PNG/src/itkpng/pngset.c
    Modules/ThirdParty/PNG/src/itkpng/pngstruct.h
    Modules/ThirdParty/PNG/src/itkpng/pngtest.c
    Modules/ThirdParty/PNG/src/itkpng/pngtrans.c
    Modules/ThirdParty/PNG/src/itkpng/pngwio.c
    Modules/ThirdParty/PNG/src/itkpng/pngwrite.c
    Modules/ThirdParty/PNG/src/itkpng/pngwtran.c
    Modules/ThirdParty/PNG/src/itkpng/pngwutil.c
Please commit your changes or stash them before you merge.
Aborting
error: The branch 'upstream-png' is not fully merged.
If you are sure you want to delete it, run 'git branch -D upstream-png'.

Also, after that, I tried to build it as normal.

mkdir build && cd build && cmake .. && make

Still get error:

../../../../lib/libitkpng-5.2.a(pngrutil.c.o):pngrutil.c:function itk_png_read_filter_row: error: undefined reference to 'png_init_filter_functions_vsx'
dzenanz commented 4 years ago

In #1962 I did a git clone, then cd Modules/ThirdParty/PNG and finally ./UpdateFromUpstream.sh. This resulted in a merge conflict over LICENSE file, which I resolved manually by choosing the existing file.

Mon-ius commented 4 years ago

I saw there is an update for https://github.com/InsightSoftwareConsortium/ITK/pull/1962. Does that mean it has no conflict now?

Mon-ius commented 4 years ago

Let conclude that:

right?

dzenanz commented 4 years ago

I manually resolved the merge conflict in #1962. But there were not a lot of changes in this update, so I doubt it will resolve your issue.

dzenanz commented 4 years ago

... or you could git pull my branch (updatePNG) and don't deal with updating.

Mon-ius commented 4 years ago

So, git clone https://github.com/dzenanz/ITK.git. And git checkout updatePNG, right?

Did you also merge the updatePNG into master on your repo?

After

Still got error:

../../../../lib/libitkpng-5.2.a(pngrutil.c.o):pngrutil.c:function itk_png_read_filter_row: error: undefined reference to 'png_init_filter_functions_vsx'
collect2: error: ld returned 1 exit status
make[2]: *** [bin/ITKIOGIPLTestDriver] Error 1
make[1]: *** [Modules/IO/GIPL/test/CMakeFiles/ITKIOGIPLTestDriver.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
dzenanz commented 4 years ago

The checkout steps seem fine. But that does not resolve your error. png_init_filter_functions_vsx does not exist on my computer. It seems to come from here: https://github.com/InsightSoftwareConsortium/ITK/blob/4bdc38ca9bedac7c2c61e29f014e902e1fe6a2e7/Modules/ThirdParty/PNG/src/itkpng/pngpriv.h#L268-L271

As far as I can tell, this is an issue in libPNG. Can you try enabling ITK_USE_SYSTEM_PNG? To do that, replace cmake .. by cmake -DITK_USE_SYSTEM_PNG=ON .. in your build command.

Mon-ius commented 4 years ago

Yes, I tried that before raised the issues. And now, I tried again with your repo. No current error, but a new one.

[ 65%] Built target ITKImageFilterBaseTestDriver
[ 65%] Building CXX object Modules/Core/Common/test/CMakeFiles/ITKCommon2TestDriver.dir/itkThreadedIteratorRangePartitionerTest2.cxx.o
[ 65%] Building CXX object Modules/Core/Transform/test/CMakeFiles/ITKTransformTestDriver.dir/itkEuler3DTransformTest.cxx.o
[ 65%] Building CXX object Modules/Core/ImageFunction/test/CMakeFiles/ITKImageFunctionTestDriver.dir/itkGaussianDerivativeImageFunctionTest.cxx.o
[ 65%] Building CXX object Modules/IO/ImageBase/test/CMakeFiles/ITKIOImageBaseTestDriver.dir/itkImageFileWriterTest.cxx.o
/castles/nr/projects/d/duanj-ai-in-medical-imaging/ITK/Modules/IO/BMP/test/itkBMPImageIOTestExtension.cxx: In function ‘bool {anonymous}::WriteSmallBmp(const string&)’:
/castles/nr/projects/d/duanj-ai-in-medical-imaging/ITK/Modules/IO/BMP/test/itkBMPImageIOTestExtension.cxx:33:78: error: narrowing conversion of ‘-1’ from ‘int’ to ‘char’ inside { } [-Wnarrowing]
                            0,  0,  0,  1, 0, 1, 0, 1, 0, 24, 0,  0, 0, -1, 0 };
                                                                              ^
[ 65%] Linking CXX executable ../../../../bin/ITKAnisotropicSmoothingTestDriver
make[2]: *** [Modules/IO/BMP/test/CMakeFiles/ITKIOBMPTestDriver.dir/itkBMPImageIOTestExtension.cxx.o] Error 1
make[2]: *** Waiting for unfinished jobs....
[ 65%] Linking CXX executable ../../../../bin/ITKAnisotropicSmoothingTestDriver
make[2]: *** [Modules/IO/BMP/test/CMakeFiles/ITKIOBMPTestDriver.dir/itkBMPImageIOTestExtension.cxx.o] Error 1
make[2]: *** Waiting for unfinished jobs....
[ 65%] Building CXX object Modules/IO/GDCM/test/CMakeFiles/ITKIOGDCMTestDriver.dir/itkGDCMSeriesReadImageWriteTest.cxx.o
[ 65%] Built target ITKAnisotropicSmoothingTestDriver
Scanning dependencies of target ITKQuadEdgeMeshTestDriver
[ 65%] Building CXX object Modules/Core/ImageFunction/test/CMakeFiles/ITKImageFunctionTestDriver.dir/itkCentralDifferenceImageFunctionTest.cxx.o
[ 65%] Building CXX object Modules/Numerics/Statistics/test/CMakeFiles/ITKStatisticsTestDriver.dir/ITKStatisticsTestDriver.cxx.o
[ 65%] Linking CXX executable ../../../../bin/ITKImageGridGTestDriver
[ 65%] Built target ITKImageGridGTestDriver
[ 65%] Building CXX object Modules/Numerics/Statistics/test/CMakeFiles/ITKStatisticsTestDriver.dir/itkDecisionRuleTest.cxx.o
[ 66%] Building CXX object Modules/Numerics/Statistics/test/CMakeFiles/ITKStatisticsTestDriver.dir/itkDenseFrequencyContainer2Test.cxx.o
[ 66%] Building CXX object Modules/IO/GDCM/test/CMakeFiles/ITKIOGDCMTestDriver.dir/itkGDCMSeriesMissingDicomTagTest.cxx.o
[ 66%] Building CXX object Modules/Core/Common/test/CMakeFiles/ITKCommon1TestDriver.dir/ITKCommon1TestDriver.cxx.o
[ 66%] Building CXX object Modules/IO/GDCM/test/CMakeFiles/ITKIOGDCMTestDriver.dir/itkGDCMSeriesStreamReadImageWriteTest.cxx.o
[ 66%] Building CXX object Modules/IO/GDCM/test/CMakeFiles/ITKIOGDCMTestDriver.dir/itkGDCMImagePositionPatientTest.cxx.o
[ 67%] Building CXX object Modules/Core/Common/test/CMakeFiles/ITKCommon1TestDriver.dir/itkImageRegionExplicitTest.cxx.o
[ 67%] Building CXX object Modules/Core/Common/test/CMakeFiles/ITKCommon2TestDriver.dir/itkThreadedIteratorRangePartitionerTest3.cxx.o
[ 67%] Building CXX object Modules/Core/Common/test/CMakeFiles/ITKCommonGTestDriver.dir/itkImageBaseGTest.cxx.o
make[1]: *** [Modules/IO/BMP/test/CMakeFiles/ITKIOBMPTestDriver.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 74%] Linking CXX executable ../../../../bin/ITKStatisticsTestDriver
[ 74%] Built target ITKStatisticsTestDriver
[ 74%] Linking CXX executable ../../../../bin/ITKCommon1TestDriver
[ 74%] Built target ITKCommon1TestDriver
make: *** [all] Error 2
Mon-ius commented 4 years ago

I saw there was a similar issue on VTK months ago https://gitlab.kitware.com/paraview/paraview/-/issues/18176. They fix it. I look into the ThirdParty folder for both VTK and ITK, it looks similar. I wonder if I can simply replace them.

dzenanz commented 4 years ago

You could maybe go to an older version of libPNG?

Taking into consideration Shawn's advice, I tried including architecture optimization subdirs, but I could not test whether that works because update script stops updating:

dzenan@corista:~/ITK-git/Modules/ThirdParty/PNG$ ./UpdateFromUpstream.sh
Upstream has no updates
Mon-ius commented 4 years ago

I currently have the libpng/1.6.37-GCCcore-8.3.0. Do you think that is too high so cause the error?

Should I try to help you test it?

I tried this one, still failed.

[ 55%] Linking CXX executable ../../../../bin/ITKCommon1TestDriver
../../../../lib/libitkpng-5.2.a(pngrutil.c.o):pngrutil.c:function itk_png_read_filter_row: error: undefined reference to 'png_init_filter_functions_vsx'
collect2: error: ld returned 1 exit status
make[2]: *** [bin/ITKCommon1TestDriver] Error 1
make[1]: *** [Modules/Core/Common/test/CMakeFiles/ITKCommon1TestDriver.dir/all] Error 2
make: *** [all] Error 2

Also, I tried your version with cmake -DITK_USE_SYSTEM_PNG=ON .. && make

 73%] Linking CXX executable ../../../../bin/ITKCommon1TestDriver
[ 73%] Built target ITKCommon1TestDriver
[ 73%] Linking CXX executable ../../../../bin/ITKStatisticsTestDriver
[ 73%] Built target ITKStatisticsTestDriver
make: *** [all] Error 2
Mon-ius commented 4 years ago

I saw the UpdateFromUpstream.sh on theupdatePNG branch:

#!/usr/bin/env bash

thirdparty_module_name='PNG'

upstream_git_url='git://github.com/dzenanz/libpng'
upstream_git_branch='master'

snapshot_author_name='LIBPNG Upstream'
snapshot_author_email='png-mng-implement@lists.sourceforge.net'

snapshot_redact_cmd=''
snapshot_relative_path='src/itkpng'
snapshot_paths='
  png*.c
  png*.h
  LICENSE
  scripts/pnglibconf.h.prebuilt
  arm
  intel
  mips
  powerpc
  '

source "${BASH_SOURCE%/*}/../../../Utilities/Maintenance/UpdateThirdPartyFromUpstream.sh"
update_from_upstream

And the one on themaster branch:

#!/usr/bin/env bash

thirdparty_module_name='PNG'

upstream_git_url='git://git.code.sf.net/p/libpng/code'
upstream_git_branch='libpng16'

snapshot_author_name='LIBPNG Upstream'
snapshot_author_email='png-mng-implement@lists.sourceforge.net'

snapshot_redact_cmd=''
snapshot_relative_path='src/itkpng'
snapshot_paths='
  png*.c
  png*.h
  LICENSE
  scripts/pnglibconf.h.prebuilt
  '

source "${BASH_SOURCE%/*}/../../../Utilities/Maintenance/UpdateThirdPartyFromUpstream.sh"
update_from_upstream

Maybe you just update the updatePNG branch and forget to checkout? That causes:

dzenan@corista:~/ITK-git/Modules/ThirdParty/PNG$ ./UpdateFromUpstream.sh
Upstream has no updates
dzenanz commented 4 years ago

Even if the update script worked as intended, I would still have to rely on you to test it. It would be good if you took over this patch (in my updatePNG branch).

Mon-ius commented 4 years ago

I test your updatePNG branch here with running ./UpdateFromUpstream.sh here:

https://github.com/InsightSoftwareConsortium/ITK/issues/1960#issuecomment-678364445

And get failed, with and without -DITK_USE_SYSTEM_PNG=ON.

I am going to test your branch again without running ./UpdateFromUpstream.sh.

Error:

../../../../lib/libitkpng-5.2.a(pngrutil.c.o):pngrutil.c:function itk_png_read_filter_row: error: undefined reference to 'png_init_filter_functions_vsx'
collect2: error: ld returned 1 exit status
make[2]: *** [bin/ITKCommon1TestDriver] Error 1
make[1]: *** [Modules/Core/Common/test/CMakeFiles/ITKCommon1TestDriver.dir/all] Error 2
make: *** [all] Error 2

Also:

Scanning dependencies of target ITKIOImageBaseTestDriver
[ 59%] Building CXX object Modules/IO/ImageBase/test/CMakeFiles/ITKIOImageBaseTestDriver.dir/ITKIOImageBaseTestDriver.cxx.o
[ 59%] Building CXX object Modules/IO/ImageBase/test/CMakeFiles/ITKIOImageBaseTestDriver.dir/itkConvertBufferTest.cxx.o
[ 59%] Building CXX object Modules/IO/ImageBase/test/CMakeFiles/ITKIOImageBaseTestDriver.dir/itkConvertBufferTest2.cxx.o
[ 59%] Building CXX object Modules/IO/ImageBase/test/CMakeFiles/ITKIOImageBaseTestDriver.dir/itkImageFileReaderTest1.cxx.o
[ 59%] Building CXX object Modules/IO/ImageBase/test/CMakeFiles/ITKIOImageBaseTestDriver.dir/itkImageFileWriterTest.cxx.o
[ 59%] Building CXX object Modules/IO/ImageBase/test/CMakeFiles/ITKIOImageBaseTestDriver.dir/itkIOCommonTest.cxx.o
[ 59%] Building CXX object Modules/IO/ImageBase/test/CMakeFiles/ITKIOImageBaseTestDriver.dir/itkIOCommonTest2.cxx.o
[ 60%] Building CXX object Modules/IO/ImageBase/test/CMakeFiles/ITKIOImageBaseTestDriver.dir/itkNumericSeriesFileNamesTest.cxx.o
[ 60%] Building CXX object Modules/IO/ImageBase/test/CMakeFiles/ITKIOImageBaseTestDriver.dir/itkRegularExpressionSeriesFileNamesTest.cxx.o
[ 60%] Building CXX object Modules/IO/ImageBase/test/CMakeFiles/ITKIOImageBaseTestDriver.dir/itkArchetypeSeriesFileNamesTest.cxx.o
[ 60%] Building CXX object Modules/IO/ImageBase/test/CMakeFiles/ITKIOImageBaseTestDriver.dir/itkLargeImageWriteConvertReadTest.cxx.o
[ 60%] Building CXX object Modules/IO/ImageBase/test/CMakeFiles/ITKIOImageBaseTestDriver.dir/itkLargeImageWriteReadTest.cxx.o
[ 60%] Building CXX object Modules/IO/ImageBase/test/CMakeFiles/ITKIOImageBaseTestDriver.dir/itkImageFileReaderDimensionsTest.cxx.o
[ 60%] Building CXX object Modules/IO/ImageBase/test/CMakeFiles/ITKIOImageBaseTestDriver.dir/itkImageFileReaderPositiveSpacingTest.cxx.o
[ 60%] Building CXX object Modules/IO/ImageBase/test/CMakeFiles/ITKIOImageBaseTestDriver.dir/itkImageFileReaderStreamingTest.cxx.o
[ 60%] Building CXX object Modules/IO/ImageBase/test/CMakeFiles/ITKIOImageBaseTestDriver.dir/itkImageFileReaderStreamingTest2.cxx.o
[ 60%] Building CXX object Modules/IO/ImageBase/test/CMakeFiles/ITKIOImageBaseTestDriver.dir/itkImageFileWriterPastingTest1.cxx.o
[ 60%] Building CXX object Modules/IO/ImageBase/test/CMakeFiles/ITKIOImageBaseTestDriver.dir/itkImageFileWriterPastingTest2.cxx.o
[ 60%] Building CXX object Modules/IO/ImageBase/test/CMakeFiles/ITKIOImageBaseTestDriver.dir/itkImageFileWriterPastingTest3.cxx.o
[ 60%] Building CXX object Modules/IO/ImageBase/test/CMakeFiles/ITKIOImageBaseTestDriver.dir/itkImageFileWriterStreamingPastingCompressingTest1.cxx.o
[ 60%] Building CXX object Modules/IO/ImageBase/test/CMakeFiles/ITKIOImageBaseTestDriver.dir/itkImageFileWriterStreamingTest1.cxx.o
[ 60%] Building CXX object Modules/IO/ImageBase/test/CMakeFiles/ITKIOImageBaseTestDriver.dir/itkImageFileWriterStreamingTest2.cxx.o
[ 60%] Building CXX object Modules/IO/ImageBase/test/CMakeFiles/ITKIOImageBaseTestDriver.dir/itkImageFileWriterTest2.cxx.o
[ 60%] Building CXX object Modules/IO/ImageBase/test/CMakeFiles/ITKIOImageBaseTestDriver.dir/itkImageFileWriterUpdateLargestPossibleRegionTest.cxx.o
[ 60%] Building CXX object Modules/IO/ImageBase/test/CMakeFiles/ITKIOImageBaseTestDriver.dir/itkImageIOBaseTest.cxx.o
[ 60%] Building CXX object Modules/IO/ImageBase/test/CMakeFiles/ITKIOImageBaseTestDriver.dir/itkImageIODirection2DTest.cxx.o
[ 60%] Building CXX object Modules/IO/ImageBase/test/CMakeFiles/ITKIOImageBaseTestDriver.dir/itkImageIODirection3DTest.cxx.o
[ 60%] Building CXX object Modules/IO/ImageBase/test/CMakeFiles/ITKIOImageBaseTestDriver.dir/itkImageIOFileNameExtensionsTests.cxx.o
[ 60%] Building CXX object Modules/IO/ImageBase/test/CMakeFiles/ITKIOImageBaseTestDriver.dir/itkImageSeriesReaderDimensionsTest.cxx.o
[ 60%] Building CXX object Modules/IO/ImageBase/test/CMakeFiles/ITKIOImageBaseTestDriver.dir/itkImageSeriesReaderSamplingTest.cxx.o
[ 60%] Building CXX object Modules/IO/ImageBase/test/CMakeFiles/ITKIOImageBaseTestDriver.dir/itkImageSeriesReaderVectorTest.cxx.o
[ 60%] Building CXX object Modules/IO/ImageBase/test/CMakeFiles/ITKIOImageBaseTestDriver.dir/itkImageSeriesWriterTest.cxx.o
[ 60%] Building CXX object Modules/IO/ImageBase/test/CMakeFiles/ITKIOImageBaseTestDriver.dir/itkIOPluginTest.cxx.o
[ 60%] Building CXX object Modules/IO/ImageBase/test/CMakeFiles/ITKIOImageBaseTestDriver.dir/itkNoiseImageFilterTest.cxx.o
[ 60%] Building CXX object Modules/IO/ImageBase/test/CMakeFiles/ITKIOImageBaseTestDriver.dir/itkMatrixImageWriteReadTest.cxx.o
[ 60%] Building CXX object Modules/IO/ImageBase/test/CMakeFiles/ITKIOImageBaseTestDriver.dir/itkReadWriteImageWithDictionaryTest.cxx.o
[ 60%] Building CXX object Modules/IO/ImageBase/test/CMakeFiles/ITKIOImageBaseTestDriver.dir/itkVectorImageReadWriteTest.cxx.o
[ 60%] Building CXX object Modules/IO/ImageBase/test/CMakeFiles/ITKIOImageBaseTestDriver.dir/itk64bitTest.cxx.o
[ 60%] Linking CXX executable ../../../../bin/ITKIOImageBaseTestDriver
[ 60%] Built target ITKIOImageBaseTestDriver
Scanning dependencies of target itkUnicodeIOTest
[ 60%] Building CXX object Modules/IO/ImageBase/test/CMakeFiles/itkUnicodeIOTest.dir/itkUnicodeIOTest.cxx.o
[ 60%] Linking CXX executable ../../../../bin/itkUnicodeIOTest
[ 60%] Built target itkUnicodeIOTest
Scanning dependencies of target ITKIOImageBase-all
[ 60%] Built target ITKIOImageBase-all
Scanning dependencies of target ITKIOBMPTestDriver
[ 60%] Building CXX object Modules/IO/BMP/test/CMakeFiles/ITKIOBMPTestDriver.dir/ITKIOBMPTestDriver.cxx.o
[ 60%] Building CXX object Modules/IO/BMP/test/CMakeFiles/ITKIOBMPTestDriver.dir/itkBMPImageIOTest2.cxx.o
[ 60%] Building CXX object Modules/IO/BMP/test/CMakeFiles/ITKIOBMPTestDriver.dir/itkBMPImageIOTest.cxx.o
[ 60%] Building CXX object Modules/IO/BMP/test/CMakeFiles/ITKIOBMPTestDriver.dir/itkBMPImageIOTest3.cxx.o
[ 60%] Building CXX object Modules/IO/BMP/test/CMakeFiles/ITKIOBMPTestDriver.dir/itkBMPImageIOTest4.cxx.o
[ 60%] Building CXX object Modules/IO/BMP/test/CMakeFiles/ITKIOBMPTestDriver.dir/itkBMPImageIOTest5.cxx.o
[ 60%] Building CXX object Modules/IO/BMP/test/CMakeFiles/ITKIOBMPTestDriver.dir/itkBMPImageIOTestExtension.cxx.o
/castles/nr/projects/d/duanj-ai-in-medical-imaging/ITK/Modules/IO/BMP/test/itkBMPImageIOTestExtension.cxx: In function ‘bool {anonymous}::WriteSmallBmp(const string&)’:
/castles/nr/projects/d/duanj-ai-in-medical-imaging/ITK/Modules/IO/BMP/test/itkBMPImageIOTestExtension.cxx:33:78: error: narrowing conversion of ‘-1’ from ‘int’ to ‘char’ inside { } [-Wnarrowing]
                            0,  0,  0,  1, 0, 1, 0, 1, 0, 24, 0,  0, 0, -1, 0 };
                                                                              ^
make[2]: *** [Modules/IO/BMP/test/CMakeFiles/ITKIOBMPTestDriver.dir/itkBMPImageIOTestExtension.cxx.o] Error 1
make[1]: *** [Modules/IO/BMP/test/CMakeFiles/ITKIOBMPTestDriver.dir/all] Error 2
make: *** [all] Error 2
dzenanz commented 4 years ago

I really don't know why it runs into link error with the system libpng. Can you double check that ITK_USE_SYSTEM_PNG is ON, either by looking into CMakeCache.txt or by looking at cmake-gui after configure step? I does not matter whether before or after the make step.

Mon-ius commented 4 years ago

The error with and without ITK_USE_SYSTEM_PNG is different.

The original is: error: undefined reference to 'png_init_filter_functions_vsx'

Whereas ITK_USE_SYSTEM_PNG is:

error: narrowing conversion of ‘-1’ from ‘int’ to ‘char’ inside { } [-Wnarrowing]
                            0,  0,  0,  1, 0, 1, 0, 1, 0, 24, 0,  0, 0, -1, 0 };
[ 65%] Linking CXX executable ../../../../bin/ITKAnisotropicSmoothingTestDriver
make[2]: *** [Modules/IO/BMP/test/CMakeFiles/ITKIOBMPTestDriver.dir/itkBMPImageIOTestExtension.cxx.o] Error 1
dzenanz commented 4 years ago

error: narrowing conversion of ‘-1’ from ‘int’ to ‘char’ inside { } [-Wnarrowing] 0, 0, 0, 1, 0, 1, 0, 1, 0, 24, 0, 0, 0, -1, 0 }; [ 65%] Linking CXX executable ../../../../bin/ITKAnisotropicSmoothingTestDriver make[2]: *** [Modules/IO/BMP/test/CMakeFiles/ITKIOBMPTestDriver.dir/itkBMPImageIOTestExtension.cxx.o] Error 1

This is a minor compile fix, unrelated to PNG. Probably just changing that -1 to 255 will solve it. Can you try that?

Mon-ius commented 4 years ago

Sure, I can try. But it is wired to transfer int to str here.

https://github.com/InsightSoftwareConsortium/ITK/blame/4bdc38ca9bedac7c2c61e29f014e902e1fe6a2e7/Modules/IO/BMP/test/itkBMPImageIOTestExtension.cxx#L32-L33.

Why it will not cause the error on X86 platform?

Mon-ius commented 4 years ago

Also, I tried to build VTK https://github.com/Kitware/VTK. I don't need to specify anything.

Just mkdir build && cd build && cmake .. && make and everything works. Don't know how they solve these issues on their code. Maybe ITK can learn something from them?

Mon-ius commented 4 years ago

Finally, I successfully build that by these steps:

dzenanz commented 4 years ago

Do you want to submit a PR with

modify Modules/IO/BMP/test/CMakeFiles/ITKIOBMPTestDriver.dir/itkBMPImageIOTestExtension.cxx by change -1 to 255

Mon-ius commented 4 years ago

Do you want to submit a PR with

modify Modules/IO/BMP/test/CMakeFiles/ITKIOBMPTestDriver.dir/itkBMPImageIOTestExtension.cxx by change -1 to 255

Sure, let me see.

Mon-ius commented 4 years ago

Failed most of the tests. Looks like it didn't work well with intel amd64 CPU. Why? The libpng related code was optimized for -1?

dzenanz commented 4 years ago

I guess a bit more thought needs to be spent about the error and its fix in a multi-platform manner.

dzenanz commented 4 years ago

Fixed by 9b7a28032ef46034f91cdc98bb99f4b3f24f270c.