Possible to compile against a conda install ITK?

I have installed ITK 5.0 using conda install libitk libitk-devel

I’m now trying to compile a c++ code against that version of ITK but I get:

In file included from /opt/local/anaconda3/envs/dream3d/include/ITK-5.0/itkImageToImageFilter.h:31:
In file included from /opt/local/anaconda3/envs/dream3d/include/ITK-5.0/itkImageSource.h:31:
In file included from /opt/local/anaconda3/envs/dream3d/include/ITK-5.0/itkProcessObject.h:31:
In file included from /opt/local/anaconda3/envs/dream3d/include/ITK-5.0/itkDataObject.h:31:
In file included from /opt/local/anaconda3/envs/dream3d/include/ITK-5.0/itkObject.h:31:
In file included from /opt/local/anaconda3/envs/dream3d/include/ITK-5.0/itkLightObject.h:21:
In file included from /opt/local/anaconda3/envs/dream3d/include/ITK-5.0/itkMacro.h:42:
In file included from /opt/local/anaconda3/envs/dream3d/include/ITK-5.0/itkConfigure.h:22:
/opt/local/anaconda3/envs/dream3d/include/ITK-5.0/itk_compiler_detection.h:158:6: error: Unsupported compiler
#    error Unsupported compiler

The offending lines in itk_compiler_detection.h is:

if ITK_COMPILER_IS_Clang

include “compilers/ITK_COMPILER_INFO_Clang_CXX.h”

else

error Unsupported compiler

endif

I am on macOS 10.15.x Catalina using Xcode tools.

(dream3d) 1037:[mjackson@Jolder:Release]% clang --version
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Any thoughts or ideas?

Just to add a bit more to this I think the issue is that conda-forge is not using Xcode to compile but and external LLVM/Clang toolkit. When this is used ITK will generate the following code from a macro:

#  if ITK_COMPILER_IS_Clang

#    include "compilers/ITK_COMPILER_INFO_Clang_CXX.h"

#  else
#    error Unsupported compiler
#  endif

but then we come along and are trying to compile with Xcode and we error out. If we actually had compiled ITK with Xcode then the following code is produced:


#  if ITK_COMPILER_IS_AppleClang

#    include "compilers/ITK_COMPILER_INFO_AppleClang_CXX.h"

#  else
#    error Unsupported compiler
#  endif

We can’t even just forcibly define ITK_COMPILER_IS_Clang because that gets wiped out at the top of the itk_compiler_detection.h file. So thoughts on this? Should I file some sort of a bug? Can I compile the anaconda package version of ITK myself and install it into my conda environment so I can get the proper defines?

Thanks

Mixing compilers proved to be problematic in the past, so that safeguard was added. I don’t use conda, so I don’t know whether you can make it use AppleClang instead of LLVM Clang.

1 Like

I’m not sure what compiler conda is using for their builds. We are using the precompiled ITK that is found on conda-forge. From the looks of it they seem to be using some version of clang.

For now I’m going to go done the path of “mixing” compilers although I’m pretty sure that isn’t going to work out in the end as there are some subtle differences between Apple clang and normal clang.

Thanks for the feedback.

The solution is to use the anaconda supplied compilers:

https://docs.conda.io/projects/conda-build/en/latest/resources/compiler-tools.html

5 Likes