3D Slicer Build Error with GCC 7 on Ubuntu 17.04

I am trying to build 3D Slicer but an error occurs, cc1 : warnings are being treated as errors.
I searched for -Werror flag to remove it but I didn’t find it. I edited my CmakeLists.txt and
wrote SET(CMAKE_CXX_FLAGS “-Wno-error”) and SET(CMAKE_C_FLAGS “-Wno-error”) also it didn’t work.
How can I solve this issue ?

Hi,

Thanks for the report.

On which operating system, using which compiler and with which options are you building ? Could you share the command line you used to configure and build the project ?

Also what are the values of the CXXFLAGS and CFLAGS environment variables ?

Operating System : Ubuntu 17.10.1
Compiler : GNU 7.2.0
Cmake Command : cmake -DCMAKE_BUILD_TYPE:STRING=Debug -DQT_QMAKE_EXECUTABLE:FILEPATH=/usr/bin/qmake -DSlicer_USE_SYSTEM_QT:BOOL=1 …/Slicer

Make Command : make -j4

Values of CXXFLAGS and CFLAGS are the same of the project I cloned only -WALL flag I removed

I was able to reproduce the error using Ubuntu 17.10 within a docker image, I will follow up with a fix.

waiting for your fix I have been trying for 3 weeks to solve this error please help

Thanks for your patience. This issue is now fixed in r26916.

Please, update your source checkout and try to build again.

Now addressing remaining issues associated with DCMTK:

In file included from /usr/include/c++/7/cstdint:35:0,
                 from /home/jcfr/Projects/Slicer-Qt4-VTK7-Ubuntu17.04-Release/DCMTK/ofstd/include/dcmtk/ofstd/ofstdinc.h:279,
                 from /home/jcfr/Projects/Slicer-Qt4-VTK7-Ubuntu17.04-Release/DCMTK/ofstd/include/dcmtk/ofstd/oftypes.h:74,
                 from /home/jcfr/Projects/Slicer-Qt4-VTK7-Ubuntu17.04-Release/DCMTK/ofstd/include/dcmtk/ofstd/ofuuid.h:27,
                 from /home/jcfr/Projects/Slicer-Qt4-VTK7-Ubuntu17.04-Release/DCMTK/ofstd/libsrc/ofuuid.cc:25:
/usr/include/c++/7/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
 #error This file requires compiler and library support \
  ^~~~~
In file included from /home/jcfr/Projects/Slicer-Qt4-VTK7-Ubuntu17.04-Release/DCMTK/ofstd/include/dcmtk/ofstd/ofuuid.h:27:0,
                 from /home/jcfr/Projects/Slicer-Qt4-VTK7-Ubuntu17.04-Release/DCMTK/ofstd/libsrc/ofuuid.cc:25:
/home/jcfr/Projects/Slicer-Qt4-VTK7-Ubuntu17.04-Release/DCMTK/ofstd/include/dcmtk/ofstd/oftypes.h:111:9: error: 'int64_t' does not name a type; did you mean '__int64_t'?
 typedef int64_t       Sint64;
         ^~~~~~~
         __int64_t
/home/jcfr/Projects/Slicer-Qt4-VTK7-Ubuntu17.04-Release/DCMTK/ofstd/include/dcmtk/ofstd/oftypes.h:125:9: error: 'uint64_t' does not name a type; did you mean '__uint64_t'?
 typedef uint64_t      Uint64;
         ^~~~~~~~
         __uint64_t
/home/jcfr/Projects/Slicer-Qt4-VTK7-Ubuntu17.04-Release/DCMTK/ofstd/include/dcmtk/ofstd/oftypes.h:145:9: error: 'Sint64' does not name a type; did you mean 'Sint16'?
 typedef Sint64 OFintptr_t;
         ^~~~~~
         Sint16
/home/jcfr/Projects/Slicer-Qt4-VTK7-Ubuntu17.04-Release/DCMTK/ofstd/include/dcmtk/ofstd/oftypes.h:150:9: error: 'Uint64' does not name a type; did you mean 'Uint16'?
 typedef Uint64 OFuintptr_t;
         ^~~~~~
         Uint16

Build issue associated with DCMTK has been fixed in r26920

This commit also updates the version of DCMTK used in Slicer to 3.6.3

@AhmadHossam10 To move forward, I suggest you build Slicer against Qt5 by passing -DQt5_DIR:PATH=/path/to/lib/cmake/Qt5

In few days, we will update the build system so that it defaults to Qt5 and support for Qt4 and C++98 will not actively be maintained and will be removed later this year.

In the mean time, here are few more errors related to ITK:

 #error This file requires compiler and library support \
  ^~~~~
In file included from /path/to/Slicer-Release/ITKv4/Modules/IO/ImageBase/include/itkImageFileWriter.hxx:34:0,
                 from /path/to/Slicer-Release/ITKv4/Modules/IO/ImageBase/include/itkImageFileWriter.h:226,
                 from /path/to/Slicer-Release/ITKv4/Modules/IO/ImageBase/include/itkImageSeriesWriter.h:23,
                 from /path/to/Slicer-Release/ITKv4/Modules/IO/ImageBase/src/itkImageSeriesWriter.cxx:18:
/path/to/Slicer-Release/ITKv4/Modules/Core/Common/include/itkImageAlgorithm.h:57:36: error: 'true_type' in namespace 'std' does not name a type
     typedef ITK_STD_TR1_NAMESPACE::true_type  TrueType;
                                    ^~~~~~~~~
/path/to/Slicer-Release/ITKv4/Modules/Core/Common/include/itkImageAlgorithm.h:58:36: error: 'false_type' in namespace 'std' does not name a type
     typedef ITK_STD_TR1_NAMESPACE::false_type FalseType;
                                    ^~~~~~~~~~
/path/to/Slicer-Release/ITKv4/Modules/Core/Common/include/itkImageAlgorithm.h: In static member function 'static void itk::ImageAlgorithm::Copy(const itk::Image<TPixel1, VImageDimension>*, itk::Image<TPixel2, VImageDimension>*, const typename itk::Image<TPixel1, VImageDimension>::RegionType&, const typename itk::Image<TPixel2, VImageDimension>::RegionType&)':
/path/to/Slicer-Release/ITKv4/Modules/Core/Common/include/itkImageAlgorithm.h:104:61: error: 'is_convertible' is not a member of 'std'
                                    , ITK_STD_TR1_NAMESPACE::is_convertible<typename _ImageType1::PixelType,
                                                             ^~~~~~~~~~~~~~
/path/to/Slicer-Release/ITKv4/Modules/Core/Common/include/itkImageAlgorithm.h:104:61: note: suggested alternative: '__convert_to_v'
                                    , ITK_STD_TR1_NAMESPACE::is_convertible<typename _ImageType1::PixelType,
                                                             ^~~~~~~~~~~~~~
                                                             __convert_to_v
/path/to/Slicer-Release/ITKv4/Modules/Core/Common/include/itkImageAlgorithm.h:104:107: error: expected '(' before ',' token
                                    , ITK_STD_TR1_NAMESPACE::is_convertible<typename _ImageType1::PixelType,
                                                                                                           ^
/path/to/Slicer-Release/ITKv4/Modules/Core/Common/include/itkImageAlgorithm.h:105:67: error: expected '(' before '>' token
                                    typename _ImageType2::PixelType>()
                                                                   ^
/path/to/Slicer-Release/ITKv4/Modules/Core/Common/include/itkImageAlgorithm.h:105:69: error: expected primary-expression before ')' token
                                    typename _ImageType2::PixelType>()
                                                                     ^
/path/to/Slicer-Release/ITKv4/Modules/Core/Common/include/itkImageAlgorithm.h: In static member function 'static void itk::ImageAlgorithm::Copy(const itk::VectorImage<TPixel1, VImageDimension>*, itk::VectorImage<TPixel2, VImageDimension>*, const typename itk::VectorImage<TPixel1, VImageDimension>::RegionType&, const typename itk::VectorImage<TPixel2, VImageDimension>::RegionType&)':
/path/to/Slicer-Release/ITKv4/Modules/Core/Common/include/itkImageAlgorithm.h:125:61: error: 'is_convertible' is not a member of 'std'
                                    , ITK_STD_TR1_NAMESPACE::is_convertible<typename _ImageType1::PixelType,
                                                             ^~~~~~~~~~~~~~
/path/to/Slicer-Release/ITKv4/Modules/Core/Common/include/itkImageAlgorithm.h:125:61: note: suggested alternative: '__convert_to_v'
                                    , ITK_STD_TR1_NAMESPACE::is_convertible<typename _ImageType1::PixelType,
                                                             ^~~~~~~~~~~~~~
                                                             __convert_to_v
/path/to/Slicer-Release/ITKv4/Modules/Core/Common/include/itkImageAlgorithm.h:125:107: error: expected '(' before ',' token
                                    , ITK_STD_TR1_NAMESPACE::is_convertible<typename _ImageType1::PixelType,
                                                                                                           ^
/path/to/Slicer-Release/ITKv4/Modules/Core/Common/include/itkImageAlgorithm.h:126:67: error: expected '(' before '>' token
                                    typename _ImageType2::PixelType>()
                                                                   ^
/path/to/Slicer-Release/ITKv4/Modules/Core/Common/include/itkImageAlgorithm.h:126:69: error: expected primary-expression before ')' token
                                    typename _ImageType2::PixelType>()
                                                                     ^
[908/2327] Linking CXX shared library lib/libITKPath-4.13.so.1
[909/2327] Building CXX object Modules/IO/ImageBase/src/CMakeFiles/ITKIOImageBase.dir/itkImageFileWriter.cxx.o
FAILED: Modules/IO/ImageBase/src/CMakeFiles/ITKIOImageBase.dir/itkImageFileWriter.cxx.o 
/usr/bin/c++  -DITKIOImageBase_EXPORTS -IModules/ThirdParty/KWIML/src -I/path/to/Slicer-Release/ITKv4/Modules/ThirdParty/KWIML/src -IModules/ThirdParty/KWSys/src -I/path/to/Slicer-Release/ITKv4/Modules/ThirdParty/VNL/src/vxl/v3p/netlib -I/path/to/Slicer-Release/ITKv4/Modules/ThirdParty/VNL/src/vxl/vcl -I/path/to/Slicer-Release/ITKv4/Modules/ThirdParty/VNL/src/vxl/core -IModules/ThirdParty/VNL/src/vxl/v3p/netlib -IModules/ThirdParty/VNL/src/vxl/vcl -IModules/ThirdParty/VNL/src/vxl/core -I/path/to/Slicer-Release/ITKv4/Modules/ThirdParty/VNLInstantiation/include -IModules/Core/Common -I/path/to/Slicer-Release/ITKv4/Modules/Core/Common/include -IModules/IO/ImageBase -I/path/to/Slicer-Release/ITKv4/Modules/IO/ImageBase/include -IModules/ThirdParty/KWSys/src/KWSys -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 -Wno-deprecated -Wno-invalid-offsetof -Woverloaded-virtual -Wstrict-null-sentinel  -g -fPIC -fvisibility=hidden -fvisibility-inlines-hidden   -std=c++98 -MD -MT Modules/IO/ImageBase/src/CMakeFiles/ITKIOImageBase.dir/itkImageFileWriter.cxx.o -MF Modules/IO/ImageBase/src/CMakeFiles/ITKIOImageBase.dir/itkImageFileWriter.cxx.o.d -o Modules/IO/ImageBase/src/CMakeFiles/ITKIOImageBase.dir/itkImageFileWriter.cxx.o -c /path/to/Slicer-Release/ITKv4/Modules/IO/ImageBase/src/itkImageFileWriter.cxx
In file included from /usr/include/c++/7/type_traits:35:0,
                 from /path/to/Slicer-Release/ITKv4/Modules/Core/Common/include/itkImageAlgorithm.h:24,
                 from /path/to/Slicer-Release/ITKv4/Modules/IO/ImageBase/include/itkImageFileWriter.hxx:34,
                 from /path/to/Slicer-Release/ITKv4/Modules/IO/ImageBase/include/itkImageFileWriter.h:226,
                 from /path/to/Slicer-Release/ITKv4/Modules/IO/ImageBase/src/itkImageFileWriter.cxx:18:
/usr/include/c++/7/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
 #error This file requires compiler and library support \
  ^~~~~
In file included from /path/to/Slicer-Release/ITKv4/Modules/IO/ImageBase/include/itkImageFileWriter.hxx:34:0,
                 from /path/to/Slicer-Release/ITKv4/Modules/IO/ImageBase/include/itkImageFileWriter.h:226,
                 from /path/to/Slicer-Release/ITKv4/Modules/IO/ImageBase/src/itkImageFileWriter.cxx:18:
/path/to/Slicer-Release/ITKv4/Modules/Core/Common/include/itkImageAlgorithm.h:57:36: error: 'true_type' in namespace 'std' does not name a type
     typedef ITK_STD_TR1_NAMESPACE::true_type  TrueType;
                                    ^~~~~~~~~
/path/to/Slicer-Release/ITKv4/Modules/Core/Common/include/itkImageAlgorithm.h:58:36: error: 'false_type' in namespace 'std' does not name a type
     typedef ITK_STD_TR1_NAMESPACE::false_type FalseType;
                                    ^~~~~~~~~~
/path/to/Slicer-Release/ITKv4/Modules/Core/Common/include/itkImageAlgorithm.h: In static member function 'static void itk::ImageAlgorithm::Copy(const itk::Image<TPixel1, VImageDimension>*, itk::Image<TPixel2, VImageDimension>*, const typename itk::Image<TPixel1, VImageDimension>::RegionType&, const typename itk::Image<TPixel2, VImageDimension>::RegionType&)':
/path/to/Slicer-Release/ITKv4/Modules/Core/Common/include/itkImageAlgorithm.h:104:61: error: 'is_convertible' is not a member of 'std'
                                    , ITK_STD_TR1_NAMESPACE::is_convertible<typename _ImageType1::PixelType,
                                                             ^~~~~~~~~~~~~~
/path/to/Slicer-Release/ITKv4/Modules/Core/Common/include/itkImageAlgorithm.h:104:61: note: suggested alternative: '__convert_to_v'
                                    , ITK_STD_TR1_NAMESPACE::is_convertible<typename _ImageType1::PixelType,
                                                             ^~~~~~~~~~~~~~
                                                             __convert_to_v
/path/to/Slicer-Release/ITKv4/Modules/Core/Common/include/itkImageAlgorithm.h:104:107: error: expected '(' before ',' token
                                    , ITK_STD_TR1_NAMESPACE::is_convertible<typename _ImageType1::PixelType,
                                                                                                           ^
/path/to/Slicer-Release/ITKv4/Modules/Core/Common/include/itkImageAlgorithm.h:105:67: error: expected '(' before '>' token
                                    typename _ImageType2::PixelType>()
                                                                   ^
/path/to/Slicer-Release/ITKv4/Modules/Core/Common/include/itkImageAlgorithm.h:105:69: error: expected primary-expression before ')' token
                                    typename _ImageType2::PixelType>()
                                                                     ^
/path/to/Slicer-Release/ITKv4/Modules/Core/Common/include/itkImageAlgorithm.h: In static member function 'static void itk::ImageAlgorithm::Copy(const itk::VectorImage<TPixel1, VImageDimension>*, itk::VectorImage<TPixel2, VImageDimension>*, const typename itk::VectorImage<TPixel1, VImageDimension>::RegionType&, const typename itk::VectorImage<TPixel2, VImageDimension>::RegionType&)':
/path/to/Slicer-Release/ITKv4/Modules/Core/Common/include/itkImageAlgorithm.h:125:61: error: 'is_convertible' is not a member of 'std'
                                    , ITK_STD_TR1_NAMESPACE::is_convertible<typename _ImageType1::PixelType,
                                                             ^~~~~~~~~~~~~~
/path/to/Slicer-Release/ITKv4/Modules/Core/Common/include/itkImageAlgorithm.h:125:61: note: suggested alternative: '__convert_to_v'
                                    , ITK_STD_TR1_NAMESPACE::is_convertible<typename _ImageType1::PixelType,
                                                             ^~~~~~~~~~~~~~
                                                             __convert_to_v
/path/to/Slicer-Release/ITKv4/Modules/Core/Common/include/itkImageAlgorithm.h:125:107: error: expected '(' before ',' token
                                    , ITK_STD_TR1_NAMESPACE::is_convertible<typename _ImageType1::PixelType,
                                                                                                           ^
/path/to/Slicer-Release/ITKv4/Modules/Core/Common/include/itkImageAlgorithm.h:126:67: error: expected '(' before '>' token
                                    typename _ImageType2::PixelType>()
                                                                   ^
/path/to/Slicer-Release/ITKv4/Modules/Core/Common/include/itkImageAlgorithm.h:126:69: error: expected primary-expression before ')' token
                                    typename _ImageType2::PixelType>()
                                                                     ^

ITK build error fixed in r26922

I already use c++11 instead of c++98 by updating cmakelists.txt
Thanks very much I will try and build again

In case it may be of helpful, Slicer builds nicely with Qt5 on Arch Linux using gcc 7.3.0, both in debug and release mode. If you get a working Qt5/VTK9 build, I would like to know if Volume Rendering works flawlessly on your machine, and the details of your GPU chip. TIA for providing the info.

Do you mean on Linux or on any computer? If you were interested in hearing about any computers with any OS then it is probably better to post this question as a new topic.

If you would like to build with C++11, the recommended and supported approach is this one:

cmake -DCMAKE_BUILD_TYPE:STRING=Debug \
  -DQt5_DIR:PATH=/path/to/lib/cmake/Qt5 …/Slicer

This will automatically set variables like CMAKE_CXX_STANDARD and download VTK9.

On Linux. As the OP uses Ubuntu 17.10, I thought it was understood.

@chir.set building on ubuntu 17.10, gcc 6.4, Qt5.10 (debug) I have no issue with the rendering. Tested on various nvidia gpu (760, 970, 1050).

One last question (going slightly off-topic) : are you using stock open source kernel module or Nvidia proprietary module ? Thanks.

I am currently using 384.111 installed from the ubuntu repository (which I guess are the Nvidia proprietary one)

Everything is fixed except for an error in simpleITK there’s a file that’s not found. Would you please solve this issue ?