Using cmake to build SimpleITK

Hi @Pythonsegmenter,

Yes, overall, that is generally the correct approach.

A few details to watch out for:

  1. The path to the source tree and the build tree should be short because of a command line length limitation on Windows. For example, C:\SimpleITK and C:\SimpleITK-build.

  2. Avoid spaces in your paths to prevent common errors when working on the command line.

Hope this helps,
Matt

2 Likes

Hi Matt, in your example simpleitk-build is not in the parent folder of
simpleitk so this is not necessary? I’ll try a shorter path as soon as I
can find a place to charge my battery.
Thanks!

Sorry guys, still doesn’t work. I now put the source file just here: C:\SimpleITK
and the build folder here: C:\SimpleITK-build
I ran everything from the command prompt.

I’m getting this error:

I have Visual Studio 2015, with this version it is called VS2015 x64 Native Tools Command Prompt. It sets the path to C++ compiler cl and other compiler-related tools. Just running this from an ordinary command prompt usually does not work.

Instead of the command prompt, you might use CMake-GUI, and select appropriate VS version when clicking Configure the first time.

Thanks for the reply dzenans, I downloaded the latest version of visual studios (2017) and I ran it from the VS command prompt. However the result is the same:

CMake always seems to find one of my Visual Studios compilers. Have you launch the VS GUI? Perhaps that will do some user configuration needed for your environment. Then reboot to get your environment changes.

Those same steps work on my computer. When you installed VS2017, did you chose component “Desktop development with C++”? If not, that would explain your problems. If that is not the issue, which version of CMake are you using?

To check whether path to C++ compiler has been set, type cl /? in VS command prompt. Here is the output on my computer:

**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.4.2
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************

C:\Users\Dzenan\source>cl /?
Microsoft (R) C/C++ Optimizing Compiler Version 19.11.25547 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

‘cmake’ is not recognized as an internal or external command, operable program or a patch file.

This error means that the program cmake.exe is not found in the PATH environmental variable. You can either add the appropriate path with cmake.exe to your PATH environmental, it is something like C:\Program Files\CMake\bin, or automatic addition to the PATH environmental variable may be an option in the CMake installer.

– Building for: NMake Makefiles

This may be caused by CMake trying to create NMake Makefiles before, so it will try again. To address this issue, remove the contents of C:\SimpleITK-build before running cmake again.

If C:\SimpleITK-build is already clean, then explicitly specify what CMake should generate with the -G flag, i.e.

cmake -G "Visual Studio 15 2017" C:\SimpleITK\Superbuild

Thanks Matt, I could indeed resolve this issue this way :slight_smile: Now I’m just still stuck on the C++ compiler not being found.

@blowekamp I launched the GUI, but I’ll reboot later (takes a while and i actually have to study for an exam) but it certainly has no immediate effect.

@dzenanz I don’t remember whether I chose that, is there a way to check this? The output I get is that it isn’t found:
image

Hi Matt,

I did what you said: cmake -G “Visual Studio 15 2017” C:\SimpleITK\Superbuild

This is what I got from the VS cmd prompt:

Hi @Pythonsegmenter,

It sounds like an issue with the Visual Studio installation. It may help to verify that the Visual Studio installation includes C++ development support.

1 Like

I suggest to restart your computer. To check which components you have, run “Visual Studio Installer” and click “Modify”. On my computer it is located here: C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe

1 Like

Hi guys!
Sorry it has been a while, but i had to focus on a couple of other things before continuing my building quest. You guys were right, I accidently installed a Visual studio version without the developper options. After adding the developer options to my Visual Studios installation and running the cmake command from the visual studios command prompt I advanced! So thanks a lot!

You might have noticed the usage of ‘advanced’ and not ‘worked’. This is because I got a new error :). Any ideas for this one:


The original question of this post is actually solved, should I make a new one?

Thanks for all your help

Found the solution myself, i lacked the ‘git’ program apparently :slight_smile:

Just a tip, for your guide (this one: http://simpleitk.readthedocs.io/en/master/Documentation/docs/source/building.html#recipes-formulas-short-cuts), if you want that the absolute noobs like me understand it:
-Add that ‘run the following commands’ should be done in the command prompt. I initially didn’t know where.
-Add that you should download cmake (I didn’t know it was a program)
-Add that you should download a Visual studio program with developer options
-Add that you should download git
I guess that then things would have been a lot clearer for me. It’s just some feedback. Do with it whatever you want.

Greetings

2 Likes

@Pythonsegmenter

Most of the information you want us to add actually appears at the top of the page you referenced, prerequisites section. Still, this shows us that we need to point to that section from each of the sub sections.

Your feedback is helpful, so don’t stop “complaining”, you are helping us improve the documentation and its layout for everyone’s benefit.

This pull request should address the issues:

3 Likes

Hi guys,

I still have a final follow-up question on this topic :slight_smile:

It has been a while since I first had some exams. I thought I completed the quest because I builded the package succesfully. However the package still has to be installed in python. I followed the tutorial further down and I found the necessary commands. However, when I execute them I get the error that ‘setup.py’ doesn’t exist. Which is indeed the case, but I did find ‘setup.py.in’. I found it in the source folder but I guess it should be in the build folder, but it isn’t. There’s nothing in the SimpleITK-build\SimpleITK-build folder.

Here’s a screenshot of what happens when I try to run the commands as explained in the tutorial:

As always all help is appreciated

4 posts were split to a new topic: New to ITK, facing 2 errors whole compiling

Hi Pythonsegmenter, I actually have the same problem right now. And I also pretty much went through the same problems as you, too. I couldn’t resolve this yet and couldn’t really find any useful clues on how to. Can someome help? :slight_smile:

Regards, Leon

Please create a new topic for your issue. Please clearly state the tools you are using and the step taken. Also include the error message encountered.