Compile first simpleitk c++ project for Windows

I have successfully compiled SimpleITK library, helped by Git and CMake. I have to make a parentheses: I would like to compile SimpleITK by CMake GUI, to choose what I need and what I not need, but I cannot do that, not by CMake GUI, only by command line. For instance, I don’t want Python, or R, or whatever … But, that’s it. Even so, I have compiled Simple ITK, on a local path: D:\Project\SimpleITK-build

Ok then.

So, now I intend to made some tests, on a real code. Lets get some SimpleITK code from here: https://github.com/SimpleITK/SimpleITK/blob/master/Examples/SimpleGaussian/SimpleGaussian.cxx

Or, from here: https://itk.org/SimpleITKDoxygen/html/HelloWorld_2HelloWorld_8cxx-example.html

Or

https://simpleitk.readthedocs.io/en/master/link_HelloWorld_docs.html

I put this code inside VisualStudio2017, on an console app. But what about dependencies ? How can I get them ? I would not get whole SimpleITK libraries only for that small code, right ?

So, how can I get the needed dependencies for a given SimpleITK code ?

Of course, I searched for that on internet, believe me, I didn’t found it …

Can you help me into compile the first SimpleITK app ? By now, I have worked a little bit in VTK. But not ITK or SimpleITK.

Thank you.

You need to configure your own example using CMake too. These are instructions for ITK, it should be quite similar for SimpleITK.

Instructions for compiling a SimpleITK C++ based application were just added on read-the-docs. Please provide additional details if that does not address your question.

3 Likes

Thank you for responses. I appreciated.

I guess my problems are deeper. And it comes from compiling SimpleITK.

Lets make step by step.

I compiled my test project. Code:

// sitk_example.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include "pch.h"
#include <iostream>

#include <SimpleITK.h>
#include <sitkImageOperators.h>

// create convenient namespace alias
namespace sitk = itk::simple;

int main(int argc, char* argv[])
{
	sitk::PixelIDValueEnum pixelType = sitk::sitkUInt8;
	std::vector<unsigned int> imageSize(2, 128);

	// Create a black image
	sitk::Image image(imageSize, pixelType);

	// Add a Gaussian blob to the image
	std::vector<double> blobSize(2, 64.0);
	std::vector<double> blobCenter(2, 64.0);
	image = image + sitk::GaussianSource(pixelType, imageSize, blobSize, blobCenter);

	// Write the image as a PNG file
	sitk::WriteImage(image, "blob.png");
}

Nothing complicated. I generated the solution with CMake. And when I compiled, I got:

1>------ Build started: Project: sitk_example, Configuration: Debug x64 ------
1>sitk_example.cpp
1>sitk_example.obj : error LNK2019: unresolved external symbol "public: virtual __cdecl itk::simple::Image::~Image(void)" (??1Image@simple@itk@@UEAA@XZ) referenced in function main
1>sitk_example.obj : error LNK2019: unresolved external symbol "public: class itk::simple::Image & __cdecl itk::simple::Image::operator=(class itk::simple::Image const &)" (??4Image@simple@itk@@QEAAAEAV012@AEBV012@@Z) referenced in function main
1>sitk_example.obj : error LNK2019: unresolved external symbol "public: __cdecl itk::simple::Image::Image(class std::vector<unsigned int,class std::allocator<unsigned int> > const &,enum itk::simple::PixelIDValueEnum,unsigned int)" (??0Image@simple@itk@@QEAA@AEBV?$vector@IV?$allocator@I@std@@@std@@W4PixelIDValueEnum@12@I@Z) referenced in function main
1>sitk_example.obj : error LNK2019: unresolved external symbol "void __cdecl itk::simple::WriteImage(class itk::simple::Image const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,bool,int)" (?WriteImage@simple@itk@@YAXAEBVImage@12@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@_NH@Z) referenced in function main
1>sitk_example.obj : error LNK2019: unresolved external symbol "class itk::simple::Image __cdecl itk::simple::Add(class itk::simple::Image const &,class itk::simple::Image const &)" (?Add@simple@itk@@YA?AVImage@12@AEBV312@0@Z) referenced in function "class itk::simple::Image __cdecl itk::simple::operator+(class itk::simple::Image const &,class itk::simple::Image const &)" (??Hsimple@itk@@YA?AVImage@01@AEBV201@0@Z)
1>sitk_example.obj : error LNK2019: unresolved external symbol "class itk::simple::Image __cdecl itk::simple::GaussianSource(enum itk::simple::PixelIDValueEnum,class std::vector<unsigned int,class std::allocator<unsigned int> > const &,class std::vector<double,class std::allocator<double> > const &,class std::vector<double,class std::allocator<double> > const &,double,class std::vector<double,class std::allocator<double> > const &,class std::vector<double,class std::allocator<double> > const &,class std::vector<double,class std::allocator<double> >,bool)" (?GaussianSource@simple@itk@@YA?AVImage@12@W4PixelIDValueEnum@12@AEBV?$vector@IV?$allocator@I@std@@@std@@AEBV?$vector@NV?$allocator@N@std@@@6@2N22V76@_N@Z) referenced in function main
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITKCommon-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITKIO-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITKRegistration-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITKBasicFilters0-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITK_ITKAnisotropicSmoothing-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITK_ITKAntiAlias-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITK_ITKBiasCorrection-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITK_ITKBinaryMathematicalMorphology-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITK_ITKClassifiers-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITK_ITKColormap-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITK_ITKCommon-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITK_ITKConnectedComponents-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITK_ITKConvolution-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITK_ITKCurvatureFlow-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITK_ITKDeconvolution-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITK_ITKDenoising-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITK_ITKDisplacementField-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITK_ITKDistanceMap-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITK_ITKFFT-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITK_ITKFastMarching-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITK_ITKImageCompare-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITK_ITKImageCompose-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITK_ITKImageFeature-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITK_ITKImageFilterBase-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITK_ITKImageFunction-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITK_ITKImageFusion-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITK_ITKImageGradient-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITK_ITKImageGrid-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITK_ITKImageIntensity-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITK_ITKImageLabel-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITK_ITKImageNoise-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITK_ITKImageSources-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITK_ITKImageStatistics-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITK_ITKLabelMap-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITK_ITKLabelVoting-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITK_ITKLevelSets-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITK_ITKMathematicalMorphology-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITK_ITKPDEDeformableRegistration-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITK_ITKRegionGrowing-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITK_ITKRegistrationCommon-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITK_ITKReview-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITK_ITKSmoothing-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITK_ITKSuperPixel-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITK_ITKThresholding-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITK_ITKTransform-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITK_ITKWatersheds-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITK_SimpleITKFilters-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITKBasicFilters1-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKIOBruker-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKIOHDF5-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKIOJPEG2000-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKIOLSM-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKIOMINC-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\itkminc2-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKIOMRC-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKOptimizersv4-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\itklbfgs-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKColormap-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKConvolution-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKDenoising-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKReview-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKIOGDCM-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\itkgdcmMSFF-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\itkgdcmDICT-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\itkgdcmIOD-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\itkgdcmDSED-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\itkgdcmCommon-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\itkgdcmjpeg8-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\itkgdcmjpeg12-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\itkgdcmjpeg16-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\itkgdcmopenjp2-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\itkgdcmcharls-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKIOBMP-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKIOBioRad-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKIOGE-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKIOGIPL-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKIOJPEG-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKIOTIFF-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\itktiff-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\itkjpeg-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKIOMeta-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKIONIFTI-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKniftiio-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKznz-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKIONRRD-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKNrrdIO-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKIOPNG-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\itkpng-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKIOStimulate-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKIOVTK-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKIOTransformHDF5-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\libitkhdf5_cpp_D.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\libitkhdf5_D.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKIOTransformInsightLegacy-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKIOTransformMatlab-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKOptimizers-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKQuadEdgeMesh-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKBiasCorrection-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKPolynomials-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKDiffusionTensorImage-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKIOSiemens-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKIOIPL-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKIOSpatialObjects-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKIOXML-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKIOImageBase-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKEXPAT-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKKLMRegionGrowing-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKMarkovRandomFieldsClassifiers-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\itkopenjpeg-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKVTK-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKWatersheds-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKIOTransformBase-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKTransformFactory-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKSmoothing-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKMetaIO-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\itkzlib-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKLabelMap-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKStatistics-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\itkNetlibSlatec-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKSpatialObjects-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKMesh-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKTransform-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKPath-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKCommon-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\itksys-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\itkdouble-conversion-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\ITKVNLInstantiation-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\itkvnl_algo-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\itkvnl-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\itkv3p_netlib-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\itknetlib-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\SimpleITK-build\ITK-build\lib\Debug\itkvcl-5.1.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>D:\Project\sitk_example\Debug\sitk_example.exe : fatal error LNK1120: 6 unresolved externals
1>Done building project "sitk_example.vcxproj" -- FAILED.
2>------ Skipped Build: Project: ALL_BUILD, Configuration: Debug x64 ------
2>Project not selected to build for this solution configuration 
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 1 skipped ==========

Obviously, something is not ok with my SimpleITK project. I have compiled SimpleITK with git cmd line. I cannot compiled with CMake GUI (like I did with VTK, where I had setup my fine settings, what I want, and what I don’t). Here, with command line compiling, I cannot setup anything. So, is compiled with Python and don’t need Python, I compiled with C# and don’t want C#, and so on.

How can I compile a simple project that using this excellent library, SimpleITK ?

It looks like there’s an architecture mismatch between your SimpleITK library and the example program. It seems that your library was built as 32 bit (x86), while your program is being built as 64 bit (x64). They need to be built both with the same archicture. I’d recommend 64 bit, since I’m not sure we still support 32 bit.

1 Like

Hello,

This error message:

1>D:\Project\SimpleITK-build\SimpleITK-build\lib\Debug\SimpleITKCommon-2.0.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'

Indicates that you compiled SimpleITK for the x86 architecture as does you VS GUI. But you target for the sitk_executable is x64. In the CMake configuration for the sitk_executable project, please set the architecture to it to “x86”.

1 Like

I am little bit confused. I have compiled SimpleITK only by a simple cmd commands, as far as I know:

mkdir SimpleITK-build
cd SimpleITK-build
cmake ../SimpleITK

I cannot compiled by CMake GUI (like I did with VTK). In such a way, I cannot controlled what and how to compile, as I said before. However, as the image reveal, the architecture is 64 bit.

Also, my test project has 64 bit configuration:

So, the errors are illogical, but are present …

Why can’t you use the CMake GUI to configure SimpleITK?

I’ve met another errors when I used CMake GUI and when I search for a solution, I have found those git/cmd command for compiling the SimpleITK. Lets make things clear. I will try right now to compile again SimpleITK with CMake GUI and give here the outcome.

Flaviu.

So, I have taken ITK from github, and I generated the solution with CMake GUI, for 64 bit. Successfully. (on d:\project\itk\bin) And I compiled ITK successfully.

Then, I have taken SimpleITK from github, and when I open CMake GUI, I configured properly, and on configuring I got:

CMake Error at C:/Program Files/CMake/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
  Could NOT find LuaInterp (missing: LUA_EXECUTABLE) (Required is at least
  version "5.3")
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
  CMake/FindLuaInterp.cmake:51 (find_package_handle_standard_args)
  CMake/sitkGenerateFilterSource.cmake:9 (find_package)
  Code/BasicFilters/CMakeLists.txt:4 (include)

I don’t have LUA, and I don’t want LUA:

We highly recommend you do a SuperBuild to build SimpleITK. That means point the source directory to D:/Project/SimpleITK/SuperBuild. That will build ITK and the other required tools and then build SimpleITK. Doing the SuperBuild ensures that ITK is built in the manner required by SimpleITK.

Note that the SuperBuild includes Lua, which is required to build SimpleITK.

2 Likes

Hi Dave. Now it works, Kindly thank you all of you for your support.

2 Likes

I’m happy to help and glad that you got SimpleITK to work.

1 Like

I come back because I intend to use this library, SimpleITK, in real application, not only in test console application. So, I built a MFC application. I hardly generated with CMake the solution file. And is compile now, with no errors. But soon as I insert a SimpleITK header file into my app:

#include "SimpleITK.h"

I got tones of errors:

1>------ Build started: Project: Test, Configuration: Debug x64 ------
1>Test.cpp
1>d:\project\simpleitk\code\common\include\sitkProcessObject.h(227): warning C4003: not enough arguments for function-like macro invocation 'max'
1>d:\project\simpleitk\code\common\include\sitkProcessObject.h(227): error C2589: '(': illegal token on right side of '::'
1>d:\project\simpleitk\code\common\include\sitkProcessObject.h(226): error C2062: type 'unknown-type' unexpected
1>d:\project\simpleitk\code\common\include\sitkProcessObject.h(226): error C2612: trailing ')' illegal in base/member initializer list
1>D:\Project\SimpleITK\Code\IO\include\sitkShow.h(96): error C2027: use of undefined type 'itk::ProcessObject'
.......
1>D:\Project\SimpleITK\Code\BasicFilters\include\sitkImageFilter.h(95): note: see reference to class template instantiation 'itk::itk::simple::ImageFilter<N>' being compiled
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\set(54): error C2143: syntax error: missing ',' before '<'
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\set(211): note: see reference to class template instantiation 'itk::std::set<_Kty,_Pr,_Alloc>' being compiled
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\set(60): error C2061: syntax error: identifier '_Tree'
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\set(63): error C2653: '_Mybase': is not a class or namespace name
....

I put here only a small part of my errors. In Test.cpp I wrote:

#include "SimpleITK.h"

My environment is: Win10 64bit, VS2017.

I cannot use SimpleITK in my real application yet :frowning:

You need to add:

#define NOMINMAX

before you include your windows header files.

2 Likes