diff --git a/Applications/CoreApp/MitkCoreApp.cpp b/Applications/CoreApp/MitkCoreApp.cpp index 4e3de6b38f..25e2453df9 100644 --- a/Applications/CoreApp/MitkCoreApp.cpp +++ b/Applications/CoreApp/MitkCoreApp.cpp @@ -1,38 +1,46 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #include - -#include #include +#if defined __GNUC__ && !defined __clang__ +# include +# include +# include +# include +#endif + int main(int argc, char **argv) { mitk::BaseApplication app(argc, argv); app.setApplicationName("MitkCoreApp"); app.setOrganizationName("DKFZ"); - // Preload the org.mitk.gui.qt.common plug-in (and hence also Qmitk) to speed - // up a clean-cache start. This also works around bugs in older gcc and glibc implementations, - // which have difficulties with multiple dynamic opening and closing of shared libraries with - // many global static initializers. It also helps if dependent libraries have weird static - // initialization methods and/or missing de-initialization code. - QStringList preloadLibs; - preloadLibs << "liborg_mitk_gui_qt_common"; - app.setPreloadLibraries(preloadLibs); + // Preload the org.blueberry.core.expressions plugin to work around a bug in + // GCC that leads to undefined symbols while loading certain libraries even though + // the symbols are actually defined. +#if defined __GNUC__ && !defined __clang__ + auto library = QFileInfo(argv[0]).dir().path() + "/../lib/plugins/liborg_blueberry_core_expressions.so"; + + if (!QFileInfo(library).exists()) + library = "liborg_blueberry_core_expressions"; + + app.setPreloadLibraries(QStringList() << library); +#endif app.setProperty(mitk::BaseApplication::PROP_APPLICATION, "org.mitk.qt.coreapplication"); - // Run the workbench + // Run the workbench. return app.run(); } diff --git a/Applications/Workbench/MitkWorkbench.cpp b/Applications/Workbench/MitkWorkbench.cpp index eaa6f48ed9..7234550dc4 100644 --- a/Applications/Workbench/MitkWorkbench.cpp +++ b/Applications/Workbench/MitkWorkbench.cpp @@ -1,38 +1,47 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #include - #include +#if defined __GNUC__ && !defined __clang__ +# include +# include +# include +# include +#endif + int main(int argc, char **argv) { mitk::BaseApplication app(argc, argv); app.setSingleMode(true); app.setApplicationName("MITK Workbench"); app.setOrganizationName("DKFZ"); - // Preload the org.mitk.gui.qt.ext plug-in (and hence also QmitkExt) to speed - // up a clean-cache start. This also works around bugs in older gcc and glibc implementations, - // which have difficulties with multiple dynamic opening and closing of shared libraries with - // many global static initializers. It also helps if dependent libraries have weird static - // initialization methods and/or missing de-initialization code. - QStringList preloadLibs; - preloadLibs << "liborg_mitk_gui_qt_ext"; - app.setPreloadLibraries(preloadLibs); + // Preload the org.blueberry.core.expressions plugin to work around a bug in + // GCC that leads to undefined symbols while loading certain libraries even though + // the symbols are actually defined. +#if defined __GNUC__ && !defined __clang__ + auto library = QFileInfo(argv[0]).dir().path() + "/../lib/plugins/liborg_blueberry_core_expressions.so"; + + if (!QFileInfo(library).exists()) + library = "liborg_blueberry_core_expressions"; + + app.setPreloadLibraries(QStringList() << library); +#endif app.setProperty(mitk::BaseApplication::PROP_PRODUCT, "org.mitk.gui.qt.extapplication.workbench"); // Run the workbench. return app.run(); }