SuperElastix / SimpleElastix

Multi-lingual medical image registration library
http://simpleelastix.github.io
Apache License 2.0
509 stars 149 forks source link

Missing "setup.py" after trying to compile (unsuccesfully) SimpleElastix for Windows 10 + fatal error LNK1112 #363

Closed mariavillafane closed 4 years ago

mariavillafane commented 4 years ago

Hello!

I am trying to compile SimpleElastix for windows 10, so to use the tools for image registration in python. However, after compiling, the file "setup.py" is missing - (this file should supposedly be found at C:\Users\eugen\SimpleElastix\build\SimpleITK-build\Wrapping\Python\Packaging)

Also, after trying to compile, the following 3 error-messages appear:

message01:

python36.lib(python36.dll) : fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'x86' [C:\Users\eugen\SimpleElastix\build2\SimpleITK-build\Wrapping\Python\SimpleIT K_PYTHON.vcxproj] [C:\Users\eugen\SimpleElastix\build2\SimpleITK.vcxproj]

message02:

cmTC_3f6b9.dir\Debug\testCXXCompiler.obj : fatal error LNK1112: module machine type 'x86' conflicts with target machine type 'x64' [C:\Users\eugen\SimpleElastix\build3\ITK-build\CMakeFiles\CMakeTmp\ cmTC_3f6b9.vcxproj] [C:\Users\eugen\SimpleElastix\build3\ITK.vcxproj]

message03:

cmTC_f3eaa.dir\Debug\testCCompiler.obj : fatal error LNK1112: module machine type 'x86' conflicts with target machine type 'x64' [C:\Users\eugen\SimpleElastix\build3\Lua-prefix\src\Lua-build\CMakeFi les\CMakeTmp\cmTC_f3eaa.vcxproj] [C:\Users\eugen\SimpleElastix\build3\Lua.vcxproj]

Any idea on how to tackle these? I have been looking at similar issues here (relating to fatal error LNK1112) but indicating the path in the manner suggested(*) does not seem to work and hence returning the 3 error-messages mentioned before...

Any help will be most welcome!!

Best wishes

Maria

(*) this is the way I am trying to run the compilation as per suggestions in errors related to LNK1112 - many thanks :-)! C:\Users\eugen\SimpleElastix\build3>cmake -DPYTHON_LIBRARY="C:\Users\eugen\Anaconda3\libs\python36.lib" -DPYTHON_EXECUTABLE="C:\Users\eugen\Anaconda3\python.exe" -DPYTHON_INCLUDE_DIR="C:\Users\eugen\Anaconda3\Include" -DCMAKE_GENERATOR_PLATFORM=x64 ..\SuperBuild && cmake --build .

mariavillafane commented 4 years ago

Hello All -

I managed to solve my issue and succesfully install SimpleElastix for windows 10 / python I did the following:

  1. I cloned the github folder of the project (i.e. NOT downoading it, but git-cloning) C:\Users\eugen>git clone https://github.com/SuperElastix/SimpleElastix.git

(note that some build steps failed because it could not find the .git folder)

  1. I had to instruct cmake to generate the right projectfiles and where to find my python installation: C:\Users\eugen\SimpleElastix\build>cmake -G "Visual Studio 15 2017 Win64" -T host=x64 -DPYTHON_LIBRARY="C:\Users\eugen\Anaconda3\libs\python36.lib" -DPYTHON_EXECUTABLE="C:\Users\eugen\Anaconda3\python.exe" -DPYTHON_INCLUDE_DIR="C:\Users\eugen\Anaconda3\Include" ..\SuperBuild && cmake --build .

(withouth those hints, it would generate vsxproj files for VisualStudio 2010 and the wrong target architecture and not build the python bindings at all)

03: furthermore the build would try to use a 32-bit linker by default. As a workaround I needed to setup the following environment variable: C:\Users\eugen\SimpleElastix\build\SimpleITK-build>set PreferredToolArchitecture=x64

source: https://developercommunity.visualstudio.com/content/problem/160714/memory-error-for-linker-in-vs-155-x64.html

  1. then, build C:\Users\eugen\SimpleElastix\build\SimpleITK-build>cmake --build .

  2. then, install "setup.py" in the folder C:\Users\eugen\SimpleElastix\build\SimpleITK-build\Wrapping\Python\Packaging>python setup.py install

  3. Lastly, I got the following error message: error: can't copy 'C:\Users\eugen\SimpleElastix\build\SimpleITK-build\Wrapping\Python\Packaging_SimpleITKd.pyd': doesn't exist or not a regular file

...which I solved by just copying "_SimpleITKd.pyd" into the folder C:\Users\eugen\SimpleElastix\build\SimpleITK-build\Wrapping\Python\Packaging

  1. Then I was able to find my precious python egg under: C:\Users\eugen>python -m easy_install C:\Users\eugen\SimpleElastix\build\SimpleITK-build\Wrapping\Python\Packaging\dist\SimpleITK-1.2.0rc2.dev1167+gd4cf2-py3.8-win-amd64.egg

Note: the name of the egg is confusingly indicating that it is for python 3.8 although I've built it for 3.6)

Good luck to all :-)