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

成功编译后得到如图所示的界面:

本文转自博客园Grandyang的博客,原文链接:3D Slicer 4.7.0 VS 2010 Compile 编译,如需转载请自行联系原博主。

相关文章
|
Java API Android开发
Gradle 依赖关系中 compile和 implementation的区别
将在一个项目中展示implementation,api以及compile之间的差异。 假设我有一个包含三个Gradle模块的项目: • app(Android应用) • my-android-library(Android库) • my-java-library(Java库) app具有my-android-library与依赖。my-android-library具有my-java-library依赖。
594 0
|
程序员 Linux Android开发
libYuv编译
安卓使用NDK编译libYuv库
475 0
|
存储 自然语言处理 编译器
编译链接(Compile Link)
编译链接(Compile Link)
154 0
|
机器学习/深度学习 运维 自然语言处理
系统程序的编译与处理
系统程序的编译与处理
|
缓存 Java Shell
ThingsBoard详细编译指南2.4.3
ThingsBoard详细编译指南2.4.3
651 0
jpegNPP编译为so
jpegNPP编译为so
87 0
|
开发者 Python
Re.compile 方法的使用 | 学习笔记
快速学习 Re.compile 方法的使用
|
XML IDE Java
编程开发中的Compile、Make、Build详细对比
编程开发中的Compile、Make、Build详细对比
399 0
编程开发中的Compile、Make、Build详细对比
|
Web App开发 存储 缓存
V8 编译浅谈
本文是一个 V8 编译原理知识的介绍文章,旨在让大家感性的了解 JavaScript 在 V8 中的解析过程。
V8 编译浅谈
|
编译器 开发工具 IDE
编译问题汇总
每次在编译各类第三方库的时候都会碰到很多问题,基本上都是通过Google解决,其实简单反思一下就会发现是对于系统了解的不够,对于各类标准也是了解甚少。所以一而再再而三发生的问题其实是可以尽量去避免的。
1970 0