KitwareMedical / ImageViewer

A lightweight, cross-platform 2D/3D medical image viewer.
Apache License 2.0
40 stars 29 forks source link

Error during build #92

Closed tapphughesn closed 3 years ago

tapphughesn commented 3 years ago

Hi,

I got this error after building ImageViewer on my Ubuntu 20.04 system and using "make".

(base) nicholas:~/dev/ImageViewer-BUILD$ make
Consolidate compiler generated dependencies of target QtImageViewer
[  7%] Building CXX object QtImageViewer/CMakeFiles/QtImageViewer.dir/RulerWidget.cxx.o
/home/nicholas/dev/ImageViewer/QtImageViewer/RulerWidget.cxx: In member function ‘void RulerToolCollection::handleMouseEvent(QMouseEvent*, double*)’:
/home/nicholas/dev/ImageViewer/QtImageViewer/RulerWidget.cxx:203:83: error: cannot bind non-const lvalue reference of type ‘RulerTool::PointType3D&’ {aka ‘itk::Point<double, 3>&’} to an rvalue of type ‘RulerTool::PointType3D’ {aka ‘itk::Point<double, 3>’}
  203 | ue_ptr< RulerTool > r(new RulerTool(this->parent, RulerTool::PointType3D(index), metaDataFactory->getNext()));
      |                                                              ^~~~~~~~~~~~~~~~~~

/home/nicholas/dev/ImageViewer/QtImageViewer/RulerWidget.cxx:64:59: note:   initializing argument 2 of ‘RulerTool::RulerTool(QtGlSliceView*, RulerTool::PointType3D&, std::unique_ptr<RulerToolMetaData>)’
   64 | RulerTool::RulerTool(QtGlSliceView* parent0, PointType3D &index0, std::unique_ptr< RulerToolMetaData > metaData) :
      |                                              ~~~~~~~~~~~~~^~~~~~
make[2]: *** [QtImageViewer/CMakeFiles/QtImageViewer.dir/build.make:116: QtImageViewer/CMakeFiles/QtImageViewer.dir/RulerWidget.cxx.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:118: QtImageViewer/CMakeFiles/QtImageViewer.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
(base) nicholas:~/dev/ImageViewer-BUILD$ 

Does anyone know how I can resolve this? Thanks!

brad-t-moore commented 3 years ago

I think it wants the RulerTool constructor to define that as a const reference, but I'll dig into it. The reason why you are seeing the error is Visual Studio (which I use) is a bit more lax than gcc by default.