# Compile first simpleitk c++ project for Windows

**URL:** https://discourse.itk.org/t/compile-first-simpleitk-c-project-for-windows/2683
**Category:** Beginner Questions
**Tags:** simpleitk
**Created:** [February 4, 2020, 6:53pm UTC](https://discourse.itk.org/t/compile-first-simpleitk-c-project-for-windows/2683 "2020-02-04T18:53:38Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![flaviu2](https://discourse.itk.org/letter_avatar_proxy/v4/letter/f/74df32/32.png) [@flaviu2](https://discourse.itk.org/u/flaviu2)
#### Post date: [February 4, 2020, 6:53pm UTC](https://discourse.itk.org/t/compile-first-simpleitk-c-project-for-windows/2683/1 "2020-02-04T18:53:38Z")

</div>

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](https://github.com/SimpleITK/SimpleITK/blob/master/Examples/SimpleGaussian/SimpleGaussian.cxx)**

Or, from here: **[https://itk.org/SimpleITKDoxygen/html/HelloWorld\_2HelloWorld\_8cxx-example.html](https://itk.org/SimpleITKDoxygen/html/HelloWorld_2HelloWorld_8cxx-example.html)**

Or

**[https://simpleitk.readthedocs.io/en/master/link\_HelloWorld\_docs.html](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.

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [February 4, 2020, 7:11pm UTC](https://discourse.itk.org/t/compile-first-simpleitk-c-project-for-windows/2683/2 "2020-02-04T19:11:52Z")

</div>

You need to configure your own example using CMake too. [These](https://itk.org/Wiki/ITK/HelloInsight) are instructions for ITK, it should be quite similar for SimpleITK.

---

<div class="post-metadata">

### Author: ![zivy](https://discourse.itk.org/user_avatar/discourse.itk.org/zivy/32/1726_2.png) [@zivy](https://discourse.itk.org/u/zivy)
#### Post date: [February 4, 2020, 7:17pm UTC](https://discourse.itk.org/t/compile-first-simpleitk-c-project-for-windows/2683/3 "2020-02-04T19:17:24Z")

</div>

Instructions for compiling a SimpleITK C++ based application were just added on [read-the-docs](https://simpleitk.readthedocs.io/en/master/cmake_cplusplus.html). Please provide additional details if that does not address your question.

---

<div class="post-metadata">

### Author: ![flaviu2](https://discourse.itk.org/letter_avatar_proxy/v4/letter/f/74df32/32.png) [@flaviu2](https://discourse.itk.org/u/flaviu2)
#### Post date: [February 5, 2020, 6:31pm UTC](https://discourse.itk.org/t/compile-first-simpleitk-c-project-for-windows/2683/4 "2020-02-05T18:31:42Z")

</div>

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.

 ![Untitled2](https://discourse.itk.org/uploads/default/original/2X/e/e5a2920907153474d32c00f5c4329ece42d5038e.png)

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

---

<div class="post-metadata">

### Author: ![dchen](https://discourse.itk.org/user_avatar/discourse.itk.org/dchen/32/34_2.png) [@dchen](https://discourse.itk.org/u/dchen)
#### Post date: [February 5, 2020, 6:43pm UTC](https://discourse.itk.org/t/compile-first-simpleitk-c-project-for-windows/2683/5 "2020-02-05T18:43:29Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)
#### Post date: [February 5, 2020, 6:44pm UTC](https://discourse.itk.org/t/compile-first-simpleitk-c-project-for-windows/2683/6 "2020-02-05T18:44:55Z")

</div>

Hello,

This error message:

```auto
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”.

---

<div class="post-metadata">

### Author: ![flaviu2](https://discourse.itk.org/letter_avatar_proxy/v4/letter/f/74df32/32.png) [@flaviu2](https://discourse.itk.org/u/flaviu2)
#### Post date: [February 6, 2020, 7:14am UTC](https://discourse.itk.org/t/compile-first-simpleitk-c-project-for-windows/2683/7 "2020-02-06T07:14:39Z")

</div>

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:

 ![Untitled4](https://discourse.itk.org/uploads/default/original/2X/c/c20b3fd18a226dde62284db70715b09c58b56b8e.png)

So, the errors are illogical, but are present …

---

<div class="post-metadata">

### Author: ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)
#### Post date: [February 6, 2020, 2:37pm UTC](https://discourse.itk.org/t/compile-first-simpleitk-c-project-for-windows/2683/8 "2020-02-06T14:37:08Z")

</div>

> [@flaviu2](#):
>
> I cannot compiled by CMake GUI (like I did with VTK).

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

---

<div class="post-metadata">

### Author: ![flaviu2](https://discourse.itk.org/letter_avatar_proxy/v4/letter/f/74df32/32.png) [@flaviu2](https://discourse.itk.org/u/flaviu2)
#### Post date: [February 6, 2020, 2:46pm UTC](https://discourse.itk.org/t/compile-first-simpleitk-c-project-for-windows/2683/9 "2020-02-06T14:46:18Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![flaviu2](https://discourse.itk.org/letter_avatar_proxy/v4/letter/f/74df32/32.png) [@flaviu2](https://discourse.itk.org/u/flaviu2)
#### Post date: [February 6, 2020, 5:12pm UTC](https://discourse.itk.org/t/compile-first-simpleitk-c-project-for-windows/2683/10 "2020-02-06T17:12:40Z")

</div>

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:

 ![image](https://discourse.itk.org/uploads/default/original/2X/0/048fe4074e6b0f91562756999dd404b252050339.png)

---

<div class="post-metadata">

### Author: ![dchen](https://discourse.itk.org/user_avatar/discourse.itk.org/dchen/32/34_2.png) [@dchen](https://discourse.itk.org/u/dchen)
#### Post date: [February 6, 2020, 6:30pm UTC](https://discourse.itk.org/t/compile-first-simpleitk-c-project-for-windows/2683/11 "2020-02-06T18:30:24Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![flaviu2](https://discourse.itk.org/letter_avatar_proxy/v4/letter/f/74df32/32.png) [@flaviu2](https://discourse.itk.org/u/flaviu2)
#### Post date: [February 9, 2020, 9:25am UTC](https://discourse.itk.org/t/compile-first-simpleitk-c-project-for-windows/2683/12 "2020-02-09T09:25:25Z")

</div>

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

---

<div class="post-metadata">

### Author: ![dchen](https://discourse.itk.org/user_avatar/discourse.itk.org/dchen/32/34_2.png) [@dchen](https://discourse.itk.org/u/dchen)
#### Post date: [February 10, 2020, 1:38pm UTC](https://discourse.itk.org/t/compile-first-simpleitk-c-project-for-windows/2683/13 "2020-02-10T13:38:44Z")

</div>

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

---

<div class="post-metadata">

### Author: ![flaviu2](https://discourse.itk.org/letter_avatar_proxy/v4/letter/f/74df32/32.png) [@flaviu2](https://discourse.itk.org/u/flaviu2)
#### Post date: [February 11, 2020, 10:53am UTC](https://discourse.itk.org/t/compile-first-simpleitk-c-project-for-windows/2683/14 "2020-02-11T10:53:23Z")

</div>

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.

 ![image](https://discourse.itk.org/uploads/default/original/2X/7/78ce4eef9afeb1aaea2db57b9fb390cf89eeaa2e.png)

 ![image](https://discourse.itk.org/uploads/default/original/2X/4/465d166c03187b0b0244928b8d9bc6108e431979.png)

 ![image](https://discourse.itk.org/uploads/default/original/2X/5/57540187b0ccf7c919c5e7b3408e583bc336306f.png)

 ![image](https://discourse.itk.org/uploads/default/original/2X/7/74b4aeb518fcd4aa9435e1b0cb855e3dba23f310.png)

I cannot use SimpleITK in my real application yet ☹

---

<div class="post-metadata">

### Author: ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)
#### Post date: [February 11, 2020, 5:39pm UTC](https://discourse.itk.org/t/compile-first-simpleitk-c-project-for-windows/2683/15 "2020-02-11T17:39:05Z")

</div>

You need to add:

```auto
#define NOMINMAX

```

before you include your windows header files.

---

<div class="post-metadata">

### Author: ![flaviu2](https://discourse.itk.org/letter_avatar_proxy/v4/letter/f/74df32/32.png) [@flaviu2](https://discourse.itk.org/u/flaviu2)
#### Post date: [February 25, 2020, 2:52pm UTC](https://discourse.itk.org/t/compile-first-simpleitk-c-project-for-windows/2683/16 "2020-02-25T14:52:28Z")

</div>

This solved the issue ! Thank you.
