ITKOptimizersv4Python: LNK2005 “public: class itk::LBFGSOptimizerBaseHelperv4 * __cdecl itk::LBFGSOptimizerBasev4::GetOptimizer(void)” already defined in itkLBFGSOptimizerBasev4Python.obj
ITKVtkGlueCastXML: Custom build for ‘…[many XML files are referenced]\InsightToolkit-5.3.0\CMakeFiles\c6ae30f76813b67864f23ad496c55eea\ITKVtkGlueCastXML.rule’ exited with code 1. …with follow-up errors.
Indeed I would like to build shared ITK libraries with python wrappers since I am also building other custom python-wrapped libraries also using ITK (and building dlls on top of static libraries is generally a bad idea due to duplication of singletons etc.).
If the two problems above could/shall not be fixed (e.g. shared lib with python wrapping not possible; wrapping of ITKVtkGlue not possible), then it would be great if an understandable error message could be given from CMake while configuring.
Please let me know if I should open one or two issues on github in case my problems are valid.
ITKOptimizersv4Python: LNK2005 “public: class itk::LBFGSOptimizerBaseHelperv4 * __cdecl itk::LBFGSOptimizerBasev4::GetOptimizer(void)” already defined in itkLBFGSOptimizerBasev4Python.obj
(1) [multiply defined symbols]: After changing the order in CMakeLists.txt (your patch), the problem still exists, so maybe more steps are required. Any idea?
(2) [ITKVtkGlue] While the pure python interface might work for python, I need ITKVtkGlue on C++ level. One workaround for me would be to disable wrapping ITKVtkGlue for python (but only wrapping that module) if both ITKVtkGlue and Python wrapping are turned on - instead of letting compilation fail due to a tool crash. Is that possible?
Thanks for testing! Yes, we need to explicitly instantiate and set the export symbol macros accordingly to avoid the implicit instantiation. Another example of this is TransformBaseTemplate.
(2) [ITKVtkGlue] While the pure python interface might work for python, I need ITKVtkGlue on C++ level.
One approach is to build the ITKVtkGlue remote module separately against the ITK build and see if we can turn off wrapping in its configuration.
(1) I could fix the problem by simply making itk::LBFGSOptimizerBasev4::GetOptimizer(void) an inline function in .h (removing the implementation from .hxx). Would that be an option?
(2) The external module you have referenced does not compile, I guess that version is not compatible with the latest VTK anymore. I have fixed it on my machine by checking for ITK_WRAP_PYTHON in VtkGlue/Wrapping/CMakeLists.txt, see below. Would that be an option? I have not checked if wrapping to other languages (e.g. Java) still works and should be supported though.
If I should create a merge request, I was wondering how to do it on Windows, since the ITK docs mention a shell script for setting up git.
Thanks,
sophonet
# Python provides native conversion between ITK and VTK
if(ITK_WRAP_PYTHON)
MESSAGE("Not wrapping ITKVtkGlue for python, since native version is available https://docs.itk.org/en/latest/learn/python_quick_start.html#itk-and-vtk.")
else()
// existing wrapping code
endif()
Unfortunately, inlining is still going to result in duplicate symbols.
I guess that version is not compatible with the latest VTK anymore
Unfortunately, VTK breaks downstream builds on a regular basis.
If I should create a merge request, I was wondering how to do it on Windows, since the ITK docs mention a shell script for setting up git.
Hopefully, our contributing documentation is clear. Yes, there is a bash setup script to help setup your repository for development. On Windows, this can be run with the Git Bash shell, which comes by default with the git install for Windows. Please let us know if you have any questions or if the documentation can be improved.
Overall, looks good!, a few tweaks:
MESSAGE → message(STATUS
// existing wrapping code → return() ? (could be cleaner, but is untested)
Thanks for pointing out that the git-for-windows bash obviously could be used (sorry for having asked this). Maybe that remark could be added to the contribution documentation (just to avoid getting the same stupid question again ).
I was following the contribution docs but “git pullall” is not working on my machine (Windows, git-for-windows 2.43.0), even after running the SetupForDevelopment.sh script. Maybe this is also something that could be clarified in the contribution docs?
Git commit failed on my system locally, since the clang-format executable was not found. Instead, a a remark was printed that a clang-format binary will be downloaded when BUILD_TESTING is set to True, but I have done this on my system without success, I have neither found a clang-format executable in my build folder nor in the install folder and the git commit error message does not give a hint where to find it. Also (and this is beyond ITK, there is no clang-format binary available from the clang webpage, I could not find any precompiled Windows builds). Maybe the git commit warning message could be improved and/or the clang-format requirement (and install instructions) could be added to the contributing documentation?
With respect to the LBFGSOptimizerBasev4::GetOptimizer(): Thanks you are right. On Windows, the inline decorator tells MSVC not to generate symbols but I have read that there is no guarantee that other compilers do the same. So once I have pushed the VTKGlue wrapping fix, I will try another solution.
clang-format gets built for me, in e.g. C:\Dev\ITK-py11\ClangFormat-prefix\src\ClangFormat\clang-format.exe. When making multiple builds of ITK, the configuration sometimes gets confused and points to clang-format in the wrong build folder. If this older build is then deleted, you could end up without it. In that case, a fresh build should also build clang-format. One pre-compiled version is attached: clang-format.exe (2.4 MB)
Finally managed it, thanks. Another suggestion for the contribution docs would be to start with logging in to GitHub and fork ITK in a first step, then clone the fork. The docs page mentions to clone upstream ITK in step 3 (https://github.com/InsightSoftwareConsortium/ITK), into which pushing is not allowed.
I hope my fixes will make it into the next release 5.4 (since they are fixes). Thanks!