[vtkusers] [VTK] Creating an OS X bundle for a VTK example using Qt

Jon Haitz Legarreta jhlegarreta at vicomtech.org
Fri Dec 19 03:50:07 EST 2014


Hi there,
looks like the problem was unrelated to VTK or Qt themselves, but to the
way we were trying to create the OS X bundle through our CMakeLists.

Attached is a CMakeLists that should solve the issue.

Please note that you will need to change the {VTK_BIN_PATH} for the
location where your VTK binaries reside, for example
/Users/your_username/Development/Binaries/VTK6/bin

HTH,
JON HAITZ



On 15 December 2014 at 12:18, Jon Haitz Legarreta <jhlegarreta at vicomtech.org
> wrote:
>
> Hi there,
> we are having some trouble when trying to create an OS X bundle of an
> imaging software of our own that uses ITK, VTK and Qt.
>
> We are using VTK 6.1.0 and Qt 5.3.2. And our OS X is Yosemite (10.10).
>
> In order to track the problem down, we tried to generate such a bundle for
> one of the examples of VTK that uses Qt: QtVTKRenderWindows.
>
> The modified CMakeLists.txt is attached.
>
> We found that there seems to be a bug filed in kitware's CMake project in
> mantis [1]. It dates back to 2013. It seems to be still open.
>
> I am posting below the errors we get when trying to run our *.app just in
> case they are of any help.
>
>
> Is this a problem strictly related to CMake, or either VTK or either Qt
> for OS X platforms?
>
>
> Does anybody know how to solve this issue?
>
>
> Thank you,
> JON HAITZ
>
>
>
>
>
> [1] http://public.kitware.com/Bug/view.php?id=14365
>
> [-] Error trace:
>
> When executing the *.app, the application crashes, and OS X's crash report
> shows this message (this is just the beginning):
>
> Process:               QtVTKRenderWindows [17872]
> Path:
> /Users/USER/Desktop/QtVTKRenderWindows.app/Contents/MacOS/QtVTKRenderWindows
> Identifier:            QtVTKRenderWindows
> Version:               ??? (???)
> Code Type:             X86-64 (Native)
> Parent Process:        ??? [1]
> Responsible:           QtVTKRenderWindows [17872]
> User ID:               501
> Date/Time:             2014-12-15 10:30:23.381 +0100
> OS Version:            Mac OS X 10.10.1 (14B25)
> Report Version:        11
> Anonymous UUID:        E9092016-A746-70A3-34F4-DC5791286273
> Sleep/Wake UUID:       BAEA81DE-427D-44D8-BA6D-0189EBDA3FFD
> Time Awake Since Boot: 42000 seconds
> Time Since Wake:       5500 seconds
> Crashed Thread:        0  Dispatch queue: com.apple.main-thread
> Exception Type:        EXC_CRASH (SIGABRT)
> Exception Codes:       0x0000000000000000, 0x0000000000000000
> Application Specific Information:
> abort() called
> Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
> 0   libsystem_kernel.dylib            0x00007fff89fc9282 __pthread_kill +
> 10
> 1   libsystem_c.dylib             0x00007fff8f9bab73 abort + 129
> 2   QtCore                            0x00000001084a6649
> qt_message_fatal(QtMsgType, QMessageLogContext const&, QString const&) + 9
> 3   QtCore                            0x00000001084a7af1
> QMessageLogger::fatal(char const*, ...) const + 161
> 4   QtGui                         0x0000000108ade948
> QGuiApplicationPrivate::createPlatformIntegration() + 5672
> 5   QtGui                         0x0000000108ade96b
> QGuiApplicationPrivate::createEventDispatcher() + 27
> 6   QtCore                            0x00000001086ccc41
> QCoreApplication::init() + 113
> 7   QtCore                            0x00000001086ccbb7
> QCoreApplication::QCoreApplication(QCoreApplicationPrivate&) + 39
> 8   QtGui                         0x0000000108adc08e
> QGuiApplication::QGuiApplication(QGuiApplicationPrivate&) + 14
> 9   QtWidgets                     0x0000000109085aae
> QApplication::QApplication(int&, char**, int) + 206
> 10                                    0x0000000106c06c2c main + 60
> 11  libdyld.dylib                 0x00007fff948c85c9 start + 1
>
>
>
> If we try to execute the *.app from the command line, the error displayed
> reads:
>
> MAC0001-D:Desktop usuario$ open QtVTKRenderWindows.app
> LSOpenURLsWithRole() failed with error -10810 for the file
> /Users/usuario/Desktop/QtVTKRenderWindows.app.
> MAC0001-D:Desktop usuario$
> QtVTKRenderWindows.app/Contents/MacOS/QtVTKRenderWindows
> This application failed to start because it could not find or load the Qt
> platform plugin "cocoa".
>
> Reinstalling the application may fix this problem.
> Abort trap: 6
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20141219/b25d0435/attachment.html>
-------------- next part --------------
project(QtVTKRenderWindows)

cmake_minimum_required(VERSION 2.6)

if(POLICY CMP0020)
  cmake_policy(SET CMP0020 NEW)
endif()

find_package(VTK COMPONENTS
  vtkCommonCore
  vtkFiltersSources
  vtkGUISupportQt
  vtkIOImage
  vtkInteractionImage
)
include(${VTK_USE_FILE})


if("${VTK_QT_VERSION}" STREQUAL "")
  message(FATAL_ERROR "VTK was not built with Qt")
endif()

# Set your files and resources here
set( Srcs QtVTKRenderWindowsApp.cxx QtVTKRenderWindows.cxx)

set( Hdrs QtVTKRenderWindows.h )

set( MOC_Hdrs QtVTKRenderWindows.h )

set( UIs QtVTKRenderWindows.ui )

include_directories(
  ${CMAKE_CURRENT_BINARY_DIR}
  ${CMAKE_CURRENT_SOURCE_DIR}
)

# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)

INCLUDE(BundleUtilities)
if(VTK_QT_VERSION VERSION_GREATER "4")
  find_package(Qt5Widgets REQUIRED QUIET)
  qt5_wrap_ui(UI_Srcs ${UIs})

  # CMAKE_AUTOMOC in ON so the MocHdrs will be automatically wrapped.
  add_executable(QtVTKRenderWindows MACOSX_BUNDLE ${Srcs} ${Hdrs} ${UI_Srcs} ${MOC_Hdrs})
  qt5_use_modules(QtVTKRenderWindows Core Gui Widgets)
  target_link_libraries(QtVTKRenderWindows ${VTK_LIBRARIES})
else()
  find_package(Qt4 REQUIRED)
  include(${QT_USE_FILE})
  # Use what VTK built with
  set(QT_QMAKE_EXECUTABLE ${VTK_QT_QMAKE_EXECUTABLE} CACHE FILEPATH "")
  set(QT_MOC_EXECUTABLE ${VTK_QT_MOC_EXECUTABLE} CACHE FILEPATH "")
  set(QT_UIC_EXECUTABLE ${VTK_QT_UIC_EXECUTABLE} CACHE FILEPATH "")
  qt4_wrap_ui(UI_Srcs ${UIs})

  add_executable(QtVTKRenderWindows ${Srcs} ${Hdrs} ${UI_Srcs} ${MOC_Hdrs})
  target_link_libraries(QtVTKRenderWindows ${QT_LIBRARIES} ${VTK_LIBRARIES})
endif()

SET(QT_PLUGINS_DIR ${_qt5Gui_install_prefix}/plugins)
MESSAGE(WARNING "QT_PLUGINS_DIR:${QT_PLUGINS_DIR}")
SET(QTPLUGINS "{VTK_BIN_PATH}/QtVTKRenderWindows.app/Contents/PlugIns/platforms/libqcocoa.dylib;{VTK_BIN_PATH}/QtVTKRenderWindows.app/Contents/PlugIns/accessible/libqtaccessiblewidgets.dylib;{VTK_BIN_PATH}/QtVTKRenderWindows.app/Contents/PlugIns/accessible/libqtaccessiblequick.dylib")
MESSAGE(WARNING "QTPLUGINS:${QTPLUGINS}")
SET(QT_ADDITIONAL_PLUGINS ${QTPLUGINS})
MESSAGE(WARNING "QT_ADDITIONAL_PLUGINS:${QT_ADDITIONAL_PLUGINS}")


ADD_CUSTOM_COMMAND(TARGET QtVTKRenderWindows
  POST_BUILD
  COMMAND /usr/local/Cellar/qt5/5.3.2/bin/macdeployqt ARGS {VTK_BIN_PATH}/QtVTKRenderWindows.app
)
SET(BU_CHMOD_BUNDLE_ITEMS TRUE)
FIXUP_BUNDLE({VTK_BIN_PATH}/QtVTKRenderWindows.app "" "${QT_INSTALL_PREFIX}/bin")
VERIFY_BUNDLE_PREREQUISITES({VTK_BIN_PATH}/QtVTKRenderWindows.app QtVTKRenderWindows_BUNDLE_PREREQUISITES QtVTKRenderWindows_BUNDLE_PREREQUISITES_INFO)
MESSAGE(WARNING "QtVTKRenderWindows_BUNDLE_PREREQUISITES:${QtVTKRenderWindows_BUNDLE_PREREQUISITES}(${QtVTKRenderWindows_BUNDLE_PREREQUISITES_INFO})")


More information about the vtkusers mailing list