Build error on MacOSX and Linux with ITKPython enabled

It makes more sense to have this as its own topic. I think the solution to this problem is going to be very different than the solution to mine was, though I can’t immediately see what it is.

One thing that did end up helping in my case was to avoid using Xcode. I changed my CMake configuration to generate unix makefiles, and I started the superbuild with ‘make’ from the terminal.

Ok after some very deep digging I found the problem was the use of native icu library within the ofstd piece within DCMTK. Simply putting DCMTK_WITH_ICU to OFF and DCMTK_ENABLE_CHARSET_CONVERSION to inside DCMTK-build folder ccmake configuration, allows the compiling of DCMTK package. Now another error arises, I will keep searching for a solution

/Users/alex/GIT/build/slicer/ITKv4/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math.h:159:5: error: 'auto' not allowed in function return type
    auto isnan(Args&&... args) -> decltype(std::isnan(std::forward<Args>(args)...)) {
    ^~~~
/Users/alex/GIT/build/slicer/ITKv4/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math.h:159:31: error: expected ';' at end of declaration
    auto isnan(Args&&... args) -> decltype(std::isnan(std::forward<Args>(args)...)) {
                              ^
                              ;
/Users/alex/GIT/build/slicer/ITKv4/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math.h:159:32: error: cannot use arrow operator on a type
    auto isnan(Args&&... args) -> decltype(std::isnan(std::forward<Args>(args)...)) {
                               ^
/Users/alex/GIT/build/slicer/ITKv4/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math.h:163:5: error: 'auto' not allowed in function return type
    auto isinf(Args&&... args) -> decltype(std::isinf(std::forward<Args>(args)...)) {
    ^~~~
/Users/alex/GIT/build/slicer/ITKv4/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math.h:163:31: error: expected ';' at end of declaration
    auto isinf(Args&&... args) -> decltype(std::isinf(std::forward<Args>(args)...)) {
                              ^
                              ;
/Users/alex/GIT/build/slicer/ITKv4/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math.h:163:32: error: cannot use arrow operator on a type
    auto isinf(Args&&... args) -> decltype(std::isinf(std::forward<Args>(args)...)) {
                               ^
/Users/alex/GIT/build/slicer/ITKv4/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math.h:167:5: error: 'auto' not allowed in function return type
    auto isfinite(Args&&... args) -> decltype(std::isfinite(std::forward<Args>(args)...)) {
    ^~~~
/Users/alex/GIT/build/slicer/ITKv4/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math.h:167:34: error: expected ';' at end of declaration
    auto isfinite(Args&&... args) -> decltype(std::isfinite(std::forward<Args>(args)...)) {
                                 ^
                                 ;
/Users/alex/GIT/build/slicer/ITKv4/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math.h:167:35: error: cannot use arrow operator on a type
    auto isfinite(Args&&... args) -> decltype(std::isfinite(std::forward<Args>(args)...)) {
                                  ^
/Users/alex/GIT/build/slicer/ITKv4/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math.h:171:5: error: 'auto' not allowed in function return type
    auto isnormal(Args&&... args) -> decltype(std::isnormal(std::forward<Args>(args)...)) {
    ^~~~
/Users/alex/GIT/build/slicer/ITKv4/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math.h:171:34: error: expected ';' at end of declaration
    auto isnormal(Args&&... args) -> decltype(std::isnormal(std::forward<Args>(args)...)) {
                                 ^
                                 ;
/Users/alex/GIT/build/slicer/ITKv4/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math.h:171:35: error: cannot use arrow operator on a type
    auto isnormal(Args&&... args) -> decltype(std::isnormal(std::forward<Args>(args)...)) {
                                  ^
/Users/alex/GIT/build/slicer/ITKv4/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math.h:175:5: error: 'auto' not allowed in function return type
    auto max(Args&&... args) -> decltype(std::max(std::forward<Args>(args)...)) {
    ^~~~
/Users/alex/GIT/build/slicer/ITKv4/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math.h:175:29: error: expected ';' at end of declaration
    auto max(Args&&... args) -> decltype(std::max(std::forward<Args>(args)...)) {
                            ^
                            ;
/Users/alex/GIT/build/slicer/ITKv4/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math.h:175:30: error: cannot use arrow operator on a type
    auto max(Args&&... args) -> decltype(std::max(std::forward<Args>(args)...)) {
                             ^
/Users/alex/GIT/build/slicer/ITKv4/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math.h:179:5: error: 'auto' not allowed in function return type
    auto min(Args&&... args) -> decltype(std::min(std::forward<Args>(args)...)) {
    ^~~~
/Users/alex/GIT/build/slicer/ITKv4/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math.h:179:29: error: expected ';' at end of declaration
    auto min(Args&&... args) -> decltype(std::min(std::forward<Args>(args)...)) {
                            ^
                            ;
/Users/alex/GIT/build/slicer/ITKv4/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math.h:179:30: error: cannot use arrow operator on a type
    auto min(Args&&... args) -> decltype(std::min(std::forward<Args>(args)...)) {
                             ^
/Users/alex/GIT/build/slicer/ITKv4/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math.h:184:5: error: 'auto' not allowed in function return type
    auto cuberoot(Args&&... args) -> decltype(std::cbrt(std::forward<Args>(args)...)) {
    ^~~~
fatal error: too many errors emitted, stopping now [-ferror-limit=]

I was able to build DCMTK in the current Slicer master (this hash) on Mac without problems, and without changing any of the default configuration setting.

macOS: 10.13.5
Xcode: 9.4.1
clang: Apple LLVM version 9.1.0 (clang-902.0.39.2)
cmake: 3.11.4

1 Like

Ok, above error is caused by the Slicer_BUILD_ITKPython option set to ON. After this the support for I18n should be disabled if you don’t have English system (the vtkMRML piece will complain about non existing file

make[5]: *** No rule to make target `/Users/alex/GIT/slicer/Libs/MRML/Widgets/Resources/Translations/qMRMLWidgets_fr.ts', needed by `Libs/MRML/Widgets/qMRMLWidgets_fr.qm'.  Stop.

) This must be fixed since it allows python use of ITK in plugins.

When you set Both options to OFF slicer starts compiling up to the MRLM package which complains about vtkMultiVolume.h was not built. Still digging

1 Like

I confirm I did not change the default OFF setting for this option.

@Alex_Vergara note that there are 2 mechanisms that expose ITK in python in Slicer:

  1. SimpleITK (enabled by default)
  2. ITKPython (disabled by default)

Perhaps you have a reason to access 2, but I wanted to make sure you are aware of 1.

Here’s the explanation of @thewtex about the differences between these two wrappings (from his response on LinkedIn to my question about the blog post announcing ITK python):

The relative pros are,

For itk:

  • Covers the entire toolkit, including processing with PointSet’s, Mesh’s, SpecializedCoordinatesImage, etc.
  • Retains the pipeline so very large images can be analyzed through streamed processing
  • The wrapping and packaging for externally developed modules is straightforward and can be built on free GitHub CI services (documentation for this is in progress)

For SimpleITK:

  • It does not have the pipeline but has a procedural interface, which is more intuitive out of the gate for folks coming from the Matlab world

Thank to both of you. I have handled all the build errors except the vtkMultiVolume one. I still don’t know which option to set in VTK to enable the build of it. copying from GitHub doesn’t work since it now complains about

In file included from /Users/alex/GIT/slicer/Modules/Loadable/VolumeRendering/MRMLDM/vtkMRMLVolumeRenderingDisplayableManager.cxx:52:
/Users/alex/GIT/build/slicer/VTKv9-build/Rendering/Volume/vtkMultiVolume.h:82:51: error: only virtual member functions can be marked 'override'
    void SetProperty(vtkVolumeProperty* property) override;

I think this might be the feature that is still being developed, and maybe some issues have not yet been identified. @cpinter should be able to comment on this one most authoritatively.

Ok just to start to, the default PythonQT configuration uses python2.7 (impossible to change right now) while VTK9 highly encourages python3 flavor, just a glitch.

I can’t see the vtkMultiVolume.h file in the default VTK clone from Slicer, it is in GitHub otherwise. maybe the problem is only to update VTK.

I see my problem, I left the VTK_MAJOR_VERSION in 7 which does not contain the vtkMultiVolume.h thing, changed to 9 and voilà. I think version 9 shall be the default to prevent this issue, since the MRML module explicitly depends on it.

OK now the build stops at CTK

/Users/alex/GIT/build/slicer/CTK-build/CTK-build/Libs/Visualization/VTK/Widgets/moc_ctkVTKMagnifyView.cpp:87:63: error: unknown type name 'QVTKWidget'; did you mean 'QWidget'?
        case 0: _t->enteredObservedWidget((*reinterpret_cast< QVTKWidget*(*)>(_a[1]))); break;
                                                              ^~~~~~~~~~
                                                              QWidget
/Users/alex/Qt/5.11.1/clang_64/lib/QtWidgets.framework/Headers/qwidget.h:128:24: note: 'QWidget' declared here
class Q_WIDGETS_EXPORT QWidget : public QObject, public QPaintDevice
                       ^
/Users/alex/GIT/build/slicer/CTK-build/CTK-build/Libs/Visualization/VTK/Widgets/moc_ctkVTKMagnifyView.cpp:87:43: error: cannot initialize a parameter of type 'QVTKOpenGLWidget *' with an lvalue of type 'QWidget *'
        case 0: _t->enteredObservedWidget((*reinterpret_cast< QVTKWidget*(*)>(_a[1]))); break;
                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/alex/GIT/build/slicer/CTK/Libs/Visualization/VTK/Widgets/ctkVTKMagnifyView.h:137:49: note: passing argument to parameter 'widget' here
  void enteredObservedWidget(QVTKOpenGLWidget * widget);
                                                ^
/Users/alex/GIT/build/slicer/CTK-build/CTK-build/Libs/Visualization/VTK/Widgets/moc_ctkVTKMagnifyView.cpp:88:60: error: unknown type name 'QVTKWidget'; did you mean 'QWidget'?
        case 1: _t->leftObservedWidget((*reinterpret_cast< QVTKWidget*(*)>(_a[1]))); break;
                                                           ^~~~~~~~~~
                                                           QWidget
/Users/alex/Qt/5.11.1/clang_64/lib/QtWidgets.framework/Headers/qwidget.h:128:24: note: 'QWidget' declared here
class Q_WIDGETS_EXPORT QWidget : public QObject, public QPaintDevice
                       ^
/Users/alex/GIT/build/slicer/CTK-build/CTK-build/Libs/Visualization/VTK/Widgets/moc_ctkVTKMagnifyView.cpp:88:40: error: cannot initialize a parameter of type 'QVTKOpenGLWidget *' with an lvalue of type 'QWidget *'
        case 1: _t->leftObservedWidget((*reinterpret_cast< QVTKWidget*(*)>(_a[1]))); break;
                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/alex/GIT/build/slicer/CTK/Libs/Visualization/VTK/Widgets/ctkVTKMagnifyView.h:138:46: note: passing argument to parameter 'widget' here
  void leftObservedWidget(QVTKOpenGLWidget * widget);
                                             ^
/Users/alex/GIT/build/slicer/CTK-build/CTK-build/Libs/Visualization/VTK/Widgets/moc_ctkVTKMagnifyView.cpp:94:52: error: unknown type name 'QVTKWidget'; did you mean 'QWidget'?
            using _t = void (ctkVTKMagnifyView::*)(QVTKWidget * );
                                                   ^~~~~~~~~~
                                                   QWidget
/Users/alex/Qt/5.11.1/clang_64/lib/QtWidgets.framework/Headers/qwidget.h:128:24: note: 'QWidget' declared here
class Q_WIDGETS_EXPORT QWidget : public QObject, public QPaintDevice
                       ^
/Users/alex/GIT/build/slicer/CTK-build/CTK-build/Libs/Visualization/VTK/Widgets/moc_ctkVTKMagnifyView.cpp:95:51: error: static_cast from 'void (ctkVTKMagnifyView::*)(QVTKOpenGLWidget *)' to '_t'
      (aka 'void (ctkVTKMagnifyView::*)(QWidget *)') is not allowed
            if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&ctkVTKMagnifyView::enteredObservedWidget)) {
                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/alex/GIT/build/slicer/CTK-build/CTK-build/Libs/Visualization/VTK/Widgets/moc_ctkVTKMagnifyView.cpp:101:52: error: unknown type name 'QVTKWidget'; did you mean 'QWidget'?
            using _t = void (ctkVTKMagnifyView::*)(QVTKWidget * );
                                                   ^~~~~~~~~~
                                                   QWidget
/Users/alex/Qt/5.11.1/clang_64/lib/QtWidgets.framework/Headers/qwidget.h:128:24: note: 'QWidget' declared here
class Q_WIDGETS_EXPORT QWidget : public QObject, public QPaintDevice
                       ^
/Users/alex/GIT/build/slicer/CTK-build/CTK-build/Libs/Visualization/VTK/Widgets/moc_ctkVTKMagnifyView.cpp:102:51: error: static_cast from 'void (ctkVTKMagnifyView::*)(QVTKOpenGLWidget *)' to '_t'
      (aka 'void (ctkVTKMagnifyView::*)(QWidget *)') is not allowed
            if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&ctkVTKMagnifyView::leftObservedWidget)) {
                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/alex/GIT/build/slicer/CTK-build/CTK-build/Libs/Visualization/VTK/Widgets/moc_ctkVTKMagnifyView.cpp:188:47: error: unknown type name 'QVTKWidget'
void ctkVTKMagnifyView::enteredObservedWidget(QVTKWidget * _t1)
                                              ^
/Users/alex/GIT/build/slicer/CTK-build/CTK-build/Libs/Visualization/VTK/Widgets/moc_ctkVTKMagnifyView.cpp:195:44: error: unknown type name 'QVTKWidget'
void ctkVTKMagnifyView::leftObservedWidget(QVTKWidget * _t1)
                                           ^
10 errors generated.
make[5]: *** [Libs/Visualization/VTK/Widgets/CMakeFiles/CTKVisualizationVTKWidgets.dir/moc_ctkVTKMagnifyView.cpp.o] Error 1
make[5]: *** Waiting for unfinished jobs....
/Users/alex/GIT/build/slicer/CTK-build/CTK-build/Libs/Visualization/VTK/Widgets/moc_ctkVTKAbstractView.cpp:187:20: error: use of undeclared identifier 'QVTKWidget'; did you mean 'VTKWidget'?
        case 16: { QVTKWidget* _r = _t->VTKWidget();
                   ^~~~~~~~~~
                   VTKWidget
/Users/alex/GIT/build/slicer/CTK/Libs/Visualization/VTK/Widgets/ctkVTKAbstractView.h:153:34: note: 'VTKWidget' declared here
  Q_INVOKABLE QVTKOpenGLWidget * VTKWidget() const;
                                 ^
/Users/alex/GIT/build/slicer/CTK-build/CTK-build/Libs/Visualization/VTK/Widgets/moc_ctkVTKAbstractView.cpp:187:20: error: call to non-static member function without an object argument
        case 16: { QVTKWidget* _r = _t->VTKWidget();
                   ^~~~~~~~~~
/Users/alex/GIT/build/slicer/CTK-build/CTK-build/Libs/Visualization/VTK/Widgets/moc_ctkVTKAbstractView.cpp:187:32: error: use of undeclared identifier '_r'
        case 16: { QVTKWidget* _r = _t->VTKWidget();
                               ^
/Users/alex/GIT/build/slicer/CTK-build/CTK-build/Libs/Visualization/VTK/Widgets/moc_ctkVTKAbstractView.cpp:188:43: error: unknown type name 'QVTKWidget'; did you mean 'QWidget'?
            if (_a[0]) *reinterpret_cast< QVTKWidget**>(_a[0]) = std::move(_r); }  break;
                                          ^~~~~~~~~~
                                          QWidget
/Users/alex/Qt/5.11.1/clang_64/lib/QtWidgets.framework/Headers/qwidget.h:128:24: note: 'QWidget' declared here
class Q_WIDGETS_EXPORT QWidget : public QObject, public QPaintDevice
                       ^
/Users/alex/GIT/build/slicer/CTK-build/CTK-build/Libs/Visualization/VTK/Widgets/moc_ctkVTKAbstractView.cpp:188:76: error: use of undeclared identifier '_r'
            if (_a[0]) *reinterpret_cast< QVTKWidget**>(_a[0]) = std::move(_r); }  break;
                                                                           ^
/Users/alex/GIT/build/slicer/CTK-build/CTK-build/Libs/Visualization/VTK/Widgets/moc_ctkVTKChartView.cpp:198:8: error: use of undeclared identifier 'QVTKWidget'; did you mean 'QWidget'?
    { &QVTKWidget::staticMetaObject, qt_meta_stringdata_ctkVTKChartView.data,
       ^~~~~~~~~~
       QWidget
/Users/alex/Qt/5.11.1/clang_64/lib/QtWidgets.framework/Headers/qwidget.h:128:24: note: 'QWidget' declared here
class Q_WIDGETS_EXPORT QWidget : public QObject, public QPaintDevice
                       ^
/Users/alex/GIT/build/slicer/CTK-build/CTK-build/Libs/Visualization/VTK/Widgets/moc_ctkVTKChartView.cpp:213:12: error: use of undeclared identifier 'QVTKWidget'; did you mean 'QWidget'?
    return QVTKWidget::qt_metacast(_clname);
           ^~~~~~~~~~
           QWidget
/Users/alex/Qt/5.11.1/clang_64/lib/QtWidgets.framework/Headers/qwidget.h:128:24: note: 'QWidget' declared here
class Q_WIDGETS_EXPORT QWidget : public QObject, public QPaintDevice
                       ^
/Users/alex/GIT/build/slicer/CTK-build/CTK-build/Libs/Visualization/VTK/Widgets/moc_ctkVTKChartView.cpp:218:11: error: use of undeclared identifier 'QVTKWidget'; did you mean 'QWidget'?
    _id = QVTKWidget::qt_metacall(_c, _id, _a);
          ^~~~~~~~~~
          QWidget
/Users/alex/Qt/5.11.1/clang_64/lib/QtWidgets.framework/Headers/qwidget.h:128:24: note: 'QWidget' declared here
class Q_WIDGETS_EXPORT QWidget : public QObject, public QPaintDevice
                       ^
5 errors generated.
make[5]: *** [Libs/Visualization/VTK/Widgets/CMakeFiles/CTKVisualizationVTKWidgets.dir/moc_ctkVTKAbstractView.cpp.o] Error 1
3 errors generated.
make[5]: *** [Libs/Visualization/VTK/Widgets/CMakeFiles/CTKVisualizationVTKWidgets.dir/moc_ctkVTKChartView.cpp.o] Error 1
make[4]: *** [Libs/Visualization/VTK/Widgets/CMakeFiles/CTKVisualizationVTKWidgets.dir/all] Error 2
make[3]: *** [all] Error 2
make[2]: *** [CTK-prefix/src/CTK-stamp/CTK-build] Error 2
make[1]: *** [CMakeFiles/CTK.dir/all] Error 2
make: *** [all] Error 2

it is like the QVTKWidget is not built

hm I erased the whole CTK folder and relaunched the build and apparently the PythonQT library was not built in my previous try when I changed VTK versions so CTK is building now.

Apparently everything is fine now, except for the high annoyance that some parts are made with python 2.7 (like PythonQT) and others are made on python3 (like VTK).

The error comes from including a VTK header, in which a virtual function is overridden without specifying the virtual keyword in the subclass. This being an error seems to be excessive, and also seems to be compiler specific. In any case, this is a bug in VTK core.

For reference, this line throws the error

overriding this function

Everything compiled fine but when I launch slicer then this happens

13

I think it is something related with QT not found in path or something

OK, fresh clone (today 27/June/2018), QT5 in custom folder installed from QT5 network installer,

in ccmake unmark SimpleITK, mark PythonQT, leave unmarked ITKPython as won’t work.

now it runs smoothly. Plugins downloaded from extension manager are not loading

Error(s):
    Cannot load library /Users/alex/GIT/build/slicer/Slicer-build/_CPack_Packages/macosx-amd64/DragNDrop/Slicer-4.9.0-2018-06-20-macosx-amd64/Slicer.app/Contents/Extensions-27262/SlicerRT/lib/Slicer-4.9/qt-loadable-modules/libqSlicerBeamsModule.dylib: (dlopen(/Users/alex/GIT/build/slicer/Slicer-build/_CPack_Packages/macosx-amd64/DragNDrop/Slicer-4.9.0-2018-06-20-macosx-amd64/Slicer.app/Contents/Extensions-27262/SlicerRT/lib/Slicer-4.9/qt-loadable-modules/libqSlicerBeamsModule.dylib, 133): Library not loaded: @rpath/Frameworks/QtMultimedia.framework/Versions/5/QtMultimedia
  Referenced from: /Users/alex/GIT/build/slicer/Slicer-build/_CPack_Packages/macosx-amd64/DragNDrop/Slicer-4.9.0-2018-06-20-macosx-amd64/Slicer.app/Contents/Extensions-27262/SlicerRT/lib/Slicer-4.9/qt-loadable-modules/libqSlicerBeamsModule.dylib
  Reason: image not found)

Plugins from the extension manager are not generally compatible with a local build, you need to build them locally also.

I just do

echo "export DYLD_FRAMEWORK_PATH=/Users/alex/Qt/5.11.1/clang_64/lib" > /Users/alex/.bash_profile

and everything magically starts working

edit: Actually it only worked temporarily since this only affects bash, for it to work completely you shall add this to ~/.MacOSX/environment.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs$
<plist version="1.0">
<dict>
        <key>DYLD_FRAMEWORK_PATH</key>
        <string>/Users/alex/Qt/5.11.1/clang_64/lib</string>
</dict>
</plist>

Yes, on Mac technically you can do that (or fix the RPATH manually). It’s not a supported configuration so YMMV – don’t complain if the nightly build ABI changes and it stops working :smile:

I shall develop a Slicer Module so I need the whole package running everywhere, so yeah I am ready to accept challenges.

If you need PythonQT that is not available in the nightly, you will need to take care of a lot of packaging both for the application and the modules. Before you spend too much time on this, I would check if make package in Slicer-build directory generates usable binaries for the platforms you need to support. I don’t know if anyone tested that.

Already tested, it works! And it accepts extensions from the WebManager!
40

1 Like