3D Slicer 4.7.0 VS 2010 Compile 編譯


 

花了將近一周的時間的,終於在VS2010成功的編譯了最新版的3D Slicer 4.7.0,感覺快要崩潰了。Slicer用了20多個外部的庫,全都要一起編譯,完整編譯一次起碼要七八個小時,光VS的Output輸出窗口有十萬多行,復制到txt中,文本內容居然有26MB之多,可怕!經過台式機和筆記本分別進行多次編譯,出錯,改錯,再編譯,再出錯,再改錯。。。總共編譯了有二三十次,終於在台式機上成功了編譯了Slicer,感覺眼淚都要掉下來了,下面整理下成功編譯的心得,希望給他人開路,不要再像博主這樣無數次嘗試:

 

1. 下載Slicer的最新代碼 (https://github.com/Slicer/Slicer)

2. 下載Qt 4.8.6 (https://download.qt.io/archive/qt/4.8/4.8.6/),博主編譯的是32位的,所以這里下載的是x86-vs2010版本的

3. 下載最新版的CMake 3.7.2, 注意這里一定要下載最新版本的,因為用老版本很可能會出錯!

4. Slicer的編譯路徑要盡可能的短,最好就放在某個盤的根目錄,比如code放在 C:/Slicer,編譯的文件放在C:/build。(血與淚的教訓啊,如果路徑名太長,會在編譯的時候可能會找不到某些頭文件)

5. 在用Cmake配置的時候,取消 Unselect Slicer_USE_NUMPY, 因為編譯這個很有可能會出錯,而且一般情況下我們用不上,所以不用選。

6. 然后就是在打開Slicer.sln后,選擇Release模式,進行編譯。

 

下面是樓主在編譯的過程中遇到的錯誤,以及改正方法:

Error 1:

44>C:\Slicer\libs\vtkitk\itkMorphologicalContourInterpolator.hxx(150): error C2668: 'pow' : ambiguous call to overloaded function [C:\build\Slicer-build\Libs\vtkITK\vtkITK.vcxproj]
44>C:\Slicer\libs\vtkitk\itkMorphologicalContourInterpolator.hxx(153): fatal error C1903: unable to recover from previous error(s); stopping compilation [C:\build\Slicer-build\Libs\vtkITK\vtkITK.vcxproj]

 

Change:

m_MinAlignIters( pow( 2, TImage::ImageDimension ) ), // smaller of this and pixel count of the search image

to:

m_MinAlignIters( pow( 2, (double)TImage::ImageDimension ) ), // smaller of this and pixel count of the search image

 

Change:

m_MaxAlignIters( pow( 6, TImage::ImageDimension ) ), // bigger of this and root of pixel count of the search image

to:

m_MaxAlignIters( pow( 6, (double)TImage::ImageDimension ) ), // bigger of this and root of pixel count of the search image

 

Error 2:

4>..\..\..\..\Slicer\Libs\vtkAddon\vtkAddonMathUtilities.cxx(264): error C2668: 'sqrt' : ambiguous call to overloaded function [C:\build\Slicer-build\Libs\vtkAddon\vtkAddon.vcxproj]
44>            c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\math.h(127): could be 'double sqrt(double)'
44>            c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\math.h(541): or       'float sqrt(float)'
44>            c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\math.h(589): or       'long double sqrt(long double)'
44>            while trying to match the argument list '(unsigned __int64)'

 

Change:

int dimension = std::sqrt(elements.size()) + 0.5; // Since conversion to int just truncates

to:

int dimension = std::sqrt((double)elements.size()) + 0.5; // Since conversion to int just truncates

 

Error 3:

44>C:\Slicer\libs\vtkitk\itkMorphologicalContourInterpolator.hxx(1284): error C2668: 'sqrt' : ambiguous call to overloaded function [C:\build\Slicer-build\Libs\vtkITK\vtkITK.vcxproj]
44>            c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\math.h(589): could be 'long double sqrt(long double)'
44>            c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\math.h(541): or       'float sqrt(float)'
44>            c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\math.h(127): or       'double sqrt(double)'
44>            while trying to match the argument list '(unsigned long)'
44>            C:\Slicer\libs\vtkitk\itkMorphologicalContourInterpolator.hxx(1243) : while compiling class template member function 'itk::Index<VIndexDimension> itk::MorphologicalContourInterpolator<TImage>::Align(itk::SmartPointer<TObjectType> &,long,itk::SmartPointer<TObjectType> &,const std::vector<_Ty> &)'

 

Change:

IdentifierType maxIter = std::max( m_MaxAlignIters, (IdentifierType)sqrt( searchRegion.GetNumberOfPixels() ) );

to:

IdentifierType maxIter = std::max( m_MaxAlignIters, (IdentifierType)sqrt( (double)searchRegion.GetNumberOfPixels() ) );

 

Error 4:

44>..\..\..\..\..\..\Slicer\Libs\MRML\Core\Testing\vtkMRMLSceneTest2.cxx(41): error C2039: 'back_inserter' : is not a member of 'std' [C:\build\Slicer-build\Libs\MRML\Core\Testing\MRMLCoreCxxTests.vcxproj]
44>..\..\..\..\..\..\Slicer\Libs\MRML\Core\Testing\vtkMRMLSceneTest2.cxx(41): error C3861: 'back_inserter': identifier not found [C:\build\Slicer-build\Libs\MRML\Core\Testing\MRMLCoreCxxTests.vcxproj]

 

Add:

#include <iterator>

 

Error 5:

44>..\..\..\..\..\..\Slicer\Modules\Loadable\Segmentations\EditorEffects\qSlicerSegmentEditorScissorsEffect.cxx(389): error C2668: 'sqrt' : ambiguous call to overloaded function [C:\build\Slicer-build\Modules\Loadable\Segmentations\EditorEffects\qSlicerSegmentationsEditorEffects.vcxproj]
44>            c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\math.h(589): could be 'long double sqrt(long double)'
44>            c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\math.h(541): or       'float sqrt(float)'
44>            c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\math.h(127): or       'double sqrt(double)'
44>            while trying to match the argument list '(int)'

 

Change:

double radius = sqrt((eventPosition[0] - this->DragStartPosition[0])*(eventPosition[0] - this->DragStartPosition[0])
          + (eventPosition[1] - this->DragStartPosition[1])*(eventPosition[1] - this->DragStartPosition[1]));

to:

double radius = sqrt((double)(eventPosition[0] - this->DragStartPosition[0])*(eventPosition[0] - this->DragStartPosition[0])
          + (eventPosition[1] - this->DragStartPosition[1])*(eventPosition[1] - this->DragStartPosition[1]));

 

Error 6:

'ACPCTransformCLP.h': No such file or directory
'AddScalarVolumesCLP.h': No such file or directory
'BRAINSDWICleanupCLP.h': No such file or directory
'BRAINSDemonWarpCLP.h': No such file or directory
'BRAINSFitCLP.h': No such file or directory
'BRAINSLabelStatsCLP.h': No such file or directory
'BRAINSROIAutoCLP.h': No such file or directory
'BRAINSResampleCLP.h': No such file or directory
'BRAINSResizeCLP.h': No such file or directory
'BRAINSStripRotationCLP.h': No such file or directory
'BRAINSTransformConvertCLP.h': No such file or directory
'BSplineToDeformationFieldCLP.h': No such file or directory
'CLIModule4TestCLP.h': No such file or directory
'CLIROITestCLP.h': No such file or directory
'CastScalarVolumeCLP.h': No such file or directory
'CheckerBoardFilterCLP.h': No such file or directory
'CreateDICOMSeriesCLP.h': No such file or directory
'CurvatureAnisotropicDiffusionCLP.h': No such file or directory
'DWIConvertCLP.h': No such file or directory
'DiffusionTensorTestCLP.h': No such file or directory
'EMSegmentCommandLineCLP.h': No such file or directory
'EMSegmentTransformToNewFormatCLP.h': No such file or directory
'ExecutionModelTourCLP.h': No such file or directory
'ExpertAutomatedRegistrationCLP.h': No such file or directory
'ExtractSkeletonCLP.h': No such file or directory
'FiducialRegistrationCLP.h': No such file or directory
'GaussianBlurImageFilterCLP.h': No such file or directory
'GradientAnisotropicDiffusionCLP.h': No such file or directory
'GrayscaleFillHoleImageFilterCLP.h': No such file or directory
'GrayscaleGrindPeakImageFilterCLP.h': No such file or directory
'GrayscaleModelMakerCLP.h': No such file or directory
'HistogramMatchingCLP.h': No such file or directory
'ImageLabelCombineCLP.h': No such file or directory
'IslandRemovalCLP.h': No such file or directory
'LabelMapSmoothingCLP.h': No such file or directory
'MaskScalarVolumeCLP.h': No such file or directory
'MedianImageFilterCLP.h': No such file or directory
'MergeModelsCLP.h': No such file or directory
'ModelMakerCLP.h': No such file or directory
'ModelToLabelMapCLP.h': No such file or directory
'MultiplyScalarVolumesCLP.h': No such file or directory
'N4ITKBiasFieldCorrectionCLP.h': No such file or directory
'OrientScalarVolumeCLP.h': No such file or directory
'OtsuThresholdImageFilterCLP.h': No such file or directory
'PETStandardUptakeValueComputationCLP.h': No such file or directory
'PerformMetricTestCLP.h': No such file or directory
'ProbeVolumeWithModelCLP.h': No such file or directory
'ResampleDTIVolumeCLP.h': No such file or directory
'ResampleScalarVectorDWIVolumeCLP.h': No such file or directory
'ResampleScalarVolumeCLP.h': No such file or directory
'RobustStatisticsSegmenterCLP.h': No such file or directory
'SimpleRegionGrowingSegmentationCLP.h': No such file or directory
'SubtractScalarVolumesCLP.h': No such file or directory
'TestGridTransformRegistrationCLP.h': No such file or directory
'ThresholdScalarVolumeCLP.h': No such file or directory
'VBRAINSDemonWarpCLP.h': No such file or directory
'VotingBinaryHoleFillingImageFilterCLP.h': No such file or directory

 

Solution:

Make the path short for CMake! For example, put Slicer source code at C:/Slicer, put the build files at C:/build

 

成功編譯后得到如圖所示的界面:

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM