Geant4 with Qt6 on MacOS Sonoma 14.5: Symbol not found: _FT_Get_Color_Glyph_ClipBox

Dear experts,
I am trying to install Geant4 on my Mac with Qt6. I am building from the source using cmake.
The cmake flags are the following:

cmake -DCMAKE_INSTALL_PREFIX=/Users/arkasantra/Geant4_Install_Qt6 -DGEANT4_INSTALL_DATA=ON -DGEANT4_BUILD_MULTITHREADED=ON -DGEANT4_USE_OPENGL_X11=ON -DGEANT4_USE_PYTHON=ON -DGEANT4_USE_QT=ON -DGEANT4_USE_QT_QT6=ON -DGEANT4_INSTALL_EXAMPLES=ON  -DGEANT4_USE_SYSTEM_ZLIB=ON -DGEANT4_BUILD_TLS_MODEL=global-dynamic -DGEANT4_USE_GDML=ON -DCMAKE_PREFIX_PATH=$(brew --prefix qt) -DCMAKE_CXX_STANDARD=20 -DGEANT4_USE_FREETYPE=ON -DGEANT4_USE_RAYTRACER_X11=ON /Users/arkasantra/geant4-v11.2.1

The configuration message from the system is the following:

-- The C compiler identification is AppleClang 15.0.0.15000309
-- The CXX compiler identification is AppleClang 15.0.0.15000309
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Checking C++ feature CXXSTDLIB_FILESYSTEM_NATIVE - Success
-- Performing Test HAVE_TLS
-- Performing Test HAVE_TLS - Success
-- Found EXPAT: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/lib/libexpat.tbd (found version "2.5.0")
-- Found ZLIB: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/lib/libz.tbd (found version "1.2.12")
-- Found XercesC: /usr/local/lib/libxerces-c.dylib (found version "3.2.5")
-- Found Freetype: /usr/local/lib/libfreetype.dylib (found version "2.13.2")
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Performing Test HAVE_STDATOMIC
-- Performing Test HAVE_STDATOMIC - Success
-- Found WrapAtomic: TRUE
-- Found OpenGL: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/System/Library/Frameworks/OpenGL.framework
-- Found WrapOpenGL: TRUE
-- Could NOT find WrapVulkanHeaders (missing: Vulkan_INCLUDE_DIR)
-- Could NOT find WrapVulkanHeaders (missing: Vulkan_INCLUDE_DIR)
-- Found XQuartzGL: /usr/X11R6/include
-- Found X11: /usr/local/include
-- Looking for XOpenDisplay in /usr/local/lib/libX11.dylib;/usr/local/lib/libXext.dylib
-- Looking for XOpenDisplay in /usr/local/lib/libX11.dylib;/usr/local/lib/libXext.dylib - found
-- Looking for gethostbyname
-- Looking for gethostbyname - found
-- Looking for connect
-- Looking for connect - found
-- Looking for remove
-- Looking for remove - found
-- Looking for shmat
-- Looking for shmat - found
-- Looking for IceConnectionNumber in ICE
-- Looking for IceConnectionNumber in ICE - found
-- Configuring download of missing dataset G4NDL (4.7)
-- Configuring download of missing dataset G4EMLOW (8.5)
-- Configuring download of missing dataset PhotonEvaporation (5.7)
-- Configuring download of missing dataset RadioactiveDecay (5.6)
-- Configuring download of missing dataset G4PARTICLEXS (4.0)
-- Configuring download of missing dataset G4PII (1.3)
-- Configuring download of missing dataset RealSurface (2.2)
-- Configuring download of missing dataset G4SAIDDATA (2.0)
-- Configuring download of missing dataset G4ABLA (3.3)
-- Configuring download of missing dataset G4INCL (1.2)
-- Configuring download of missing dataset G4ENSDFSTATE (2.3)
-- Building PTL with option BUILD_STATIC_LIBS - OFF
-- Building PTL with option BUILD_SHARED_LIBS - ON
-- Building PTL with option BUILD_OBJECT_LIBS -
-- Building PTL with CMAKE_CXX_STANDARD - 20
-- Building PTL with option PTL_USE_COVERAGE -
-- Building PTL with option PTL_USE_SANITIZER -
-- Building PTL with option PTL_USE_CLANG_TIDY -
-- Building PTL with option PTL_USE_TBB - OFF
-- Building PTL with option PTL_USE_LOCKS - OFF
-- Building PTL with option PTL_INSTALL_HEADERS - ON
-- Building PTL with option PTL_INSTALL_CONFIG - ON
CMake Warning at cmake/Modules/G4CMakeMain.cmake:78 (message):
  Geant4Py is no longer distributed with the Geant4 toolkit.  It can be
  downloaded from:

    https://github.com/koichi-murakami/g4python

  and requests for support on installation and use should be directed there.

Call Stack (most recent call first):
  CMakeLists.txt:49 (include)


-- The following Geant4 features are enabled:
CMAKE_CXX_STANDARD: Compiling against C++ Standard '20'
GEANT4_BUILD_MULTITHREADED: Build multithread enabled libraries
GEANT4_BUILD_TLS_MODEL: Building with TLS model 'global-dynamic'
GEANT4_USE_SYSTEM_EXPAT: Using system EXPAT library
GEANT4_USE_SYSTEM_ZLIB: Using system zlib library
GEANT4_USE_GDML: Building Geant4 with GDML support
GEANT4_USE_FREETYPE: Building Geant4 Analysis/Visualization with Freetype support
GEANT4_USE_OPENGL_X11: Build Geant4 OpenGL driver with X11 support
GEANT4_USE_RAYTRACER_X11: Build RayTracer driver with X11 support
GEANT4_USE_QT: Build Geant4 with Qt6 support
GEANT4_USE_QT3D: Build Geant4 Qt3D driver

-- Configuring done
-- Generating done
-- Build files have been written to: /Users/arkasantra/Geant4_Build_Qt6

The compilation using cmake --build . -j8 is successful.
Subsequently, I built the geant4-v11.2.1/examples/basic/B1 using:

cmake -DGeant4_DIR=$HOME/Geant4_Install_Qt6/lib/Geant4-11.2.1 ../B1
make -j8
make install

Again there is no issue during the compilation.

However when I am running ./exampleB1, I am getting:

dyld[42928]: Symbol not found: _FT_Get_Color_Glyph_ClipBox
  Referenced from: <CD3FC454-4C6D-38DE-904E-B105A6499B06> /usr/local/Cellar/harfbuzz/8.4.0/lib/libharfbuzz.0.dylib
  Expected in:     <8C99F699-CED2-3B79-8221-073E18249C9F> /opt/X11/lib/libfreetype.6.dylib
zsh: abort      ./exampleB1

May I know what is going wrong here? Any suggestion/comment to solve this issue will be greatly appreciated.

Thank you very much,
Arka

[ My system has qt@5 as well, but I made sure that in the PATH variable, the qt option comes first:

PATH=/usr/local/opt/openjdk/bin:/usr/local/opt/jpeg/bin:/usr/local/opt/krb5/sbin:/usr/local/opt/krb5/bin:/usr/local/opt/qt/bin:/usr/local/opt/qt@5/bin:/opt/anaconda3/bin

]

_Geant4 Version: 11.2.1
_Operating System: MacOS Sonoma 14.5, Intel Core i9
_Compiler/Version: AppleClang 15.0.0.15000309
_CMake Version: 3.25.0


As you’ve configured with a mix of Qt and X11, it looks like which Freetype library to use is getting mixed up, likely due to rpath/etc ordering. As X11 on macOS via XQuartz is using its own Freetype library, whilst Qt6 is using one from Homebrew, I think the only solution is to pick either X11 or Qt5/6 to avoid such couplings - but which is entirely up to you.

Qt is the more fully featured system, but note that issues on the Qt6 support are still being ironed out.

Dear @bmorgan ,
Thank you for the heads up.
I reinstalled Geant4 with X11 turned off and based only on Qt5.
This is the cmake command:

cmake -DCMAKE_INSTALL_PREFIX=/Users/arkasantra/Geant4_Install -DGEANT4_INSTALL_DATA=ON -DGEANT4_BUILD_MULTITHREADED=ON -DGEANT4_USE_OPENGL_X11=OFF -DGEANT4_USE_PYTHON=ON -DGEANT4_USE_QT=ON -DGEANT4_INSTALL_EXAMPLES=ON  -DGEANT4_USE_SYSTEM_ZLIB=ON -DGEANT4_BUILD_TLS_MODEL=global-dynamic -DGEANT4_USE_GDML=ON -DCMAKE_PREFIX_PATH=$(brew --prefix qt@5) -DCMAKE_CXX_STANDARD=20 /Users/arkasantra/geant4-v11.2.1

The subsequent compilation and installation went fine.

I wanted to check the examples/basic/B1, so I followed this:

cd $Geant4_Installation/examples/basic/B1
mkdir build && cd build
cmake -DCMAKE_CXX_STANDARD=20 ../
make -j8

But this time I see the compilation is NOT successful:

[ 12%] Building CXX object CMakeFiles/exampleB1.dir/exampleB1.cc.o
In file included from /Users/arkasantra/geant4-v11.2.1/examples/basic/B1/exampleB1.cc:38:
In file included from /Users/arkasantra/Geant4_Install/include/Geant4/G4VisExecutive.hh:141:
In file included from /Users/arkasantra/Geant4_Install/include/Geant4/G4VisExecutive.icc:142:
In file included from /usr/local/opt/qt@5/lib/QtCore.framework/Headers/QtGlobal:1:
/usr/local/opt/qt@5/lib/QtCore.framework/Headers/qglobal.h:399:11: error: 'maybe_unused' attribute cannot be applied to types
constexpr Q_DECL_UNUSED Deprecated_t Deprecated = {};
          ^
/usr/local/include/QtCore/qcompilerdetection.h:983:27: note: expanded from macro 'Q_DECL_UNUSED'
#  define Q_DECL_UNUSED [[maybe_unused]]
                          ^
In file included from /Users/arkasantra/geant4-v11.2.1/examples/basic/B1/exampleB1.cc:38:
In file included from /Users/arkasantra/Geant4_Install/include/Geant4/G4VisExecutive.hh:141:
In file included from /Users/arkasantra/Geant4_Install/include/Geant4/G4VisExecutive.icc:142:
In file included from /usr/local/opt/qt@5/lib/QtCore.framework/Headers/QtGlobal:1:
/usr/local/opt/qt@5/lib/QtCore.framework/Headers/qglobal.h:900:50: error: an attribute list cannot appear here
Q_REQUIRED_RESULT Q_DECL_CONSTEXPR static inline Q_DECL_UNUSED bool qFuzzyCompare(double p1, double p2)
                                                 ^~~~~~~~~~~~~
/usr/local/include/QtCore/qcompilerdetection.h:983:25: note: expanded from macro 'Q_DECL_UNUSED'
#  define Q_DECL_UNUSED [[maybe_unused]]
                        ^~~~~~~~~~~~~~~~
In file included from /Users/arkasantra/geant4-v11.2.1/examples/basic/B1/exampleB1.cc:38:
In file included from /Users/arkasantra/Geant4_Install/include/Geant4/G4VisExecutive.hh:141:
In file included from /Users/arkasantra/Geant4_Install/include/Geant4/G4VisExecutive.icc:142:
In file included from /usr/local/opt/qt@5/lib/QtCore.framework/Headers/QtGlobal:1:
/usr/local/opt/qt@5/lib/QtCore.framework/Headers/qglobal.h:905:50: error: an attribute list cannot appear here
Q_REQUIRED_RESULT Q_DECL_CONSTEXPR static inline Q_DECL_UNUSED bool qFuzzyCompare(float p1, float p2)
                                                 ^~~~~~~~~~~~~
/usr/local/include/QtCore/qcompilerdetection.h:983:25: note: expanded from macro 'Q_DECL_UNUSED'
#  define Q_DECL_UNUSED [[maybe_unused]]
                        ^~~~~~~~~~~~~~~~
In file included from /Users/arkasantra/geant4-v11.2.1/examples/basic/B1/exampleB1.cc:38:
In file included from /Users/arkasantra/Geant4_Install/include/Geant4/G4VisExecutive.hh:141:
In file included from /Users/arkasantra/Geant4_Install/include/Geant4/G4VisExecutive.icc:142:
In file included from /usr/local/opt/qt@5/lib/QtCore.framework/Headers/QtGlobal:1:
/usr/local/opt/qt@5/lib/QtCore.framework/Headers/qglobal.h:910:50: error: an attribute list cannot appear here
Q_REQUIRED_RESULT Q_DECL_CONSTEXPR static inline Q_DECL_UNUSED bool qFuzzyIsNull(double d)
                                                 ^~~~~~~~~~~~~
/usr/local/include/QtCore/qcompilerdetection.h:983:25: note: expanded from macro 'Q_DECL_UNUSED'
#  define Q_DECL_UNUSED [[maybe_unused]]
                        ^~~~~~~~~~~~~~~~
In file included from /Users/arkasantra/geant4-v11.2.1/examples/basic/B1/exampleB1.cc:38:
In file included from /Users/arkasantra/Geant4_Install/include/Geant4/G4VisExecutive.hh:141:
In file included from /Users/arkasantra/Geant4_Install/include/Geant4/G4VisExecutive.icc:142:
In file included from /usr/local/opt/qt@5/lib/QtCore.framework/Headers/QtGlobal:1:
/usr/local/opt/qt@5/lib/QtCore.framework/Headers/qglobal.h:915:50: error: an attribute list cannot appear here
Q_REQUIRED_RESULT Q_DECL_CONSTEXPR static inline Q_DECL_UNUSED  bool qFuzzyIsNull(float f)
                                                 ^~~~~~~~~~~~~
/usr/local/include/QtCore/qcompilerdetection.h:983:25: note: expanded from macro 'Q_DECL_UNUSED'
#  define Q_DECL_UNUSED [[maybe_unused]]
                        ^~~~~~~~~~~~~~~~
In file included from /Users/arkasantra/geant4-v11.2.1/examples/basic/B1/exampleB1.cc:38:
In file included from /Users/arkasantra/Geant4_Install/include/Geant4/G4VisExecutive.hh:141:
In file included from /Users/arkasantra/Geant4_Install/include/Geant4/G4VisExecutive.icc:142:
In file included from /usr/local/opt/qt@5/lib/QtCore.framework/Headers/QtGlobal:1:
/usr/local/opt/qt@5/lib/QtCore.framework/Headers/qglobal.h:925:50: error: an attribute list cannot appear here
Q_REQUIRED_RESULT Q_DECL_CONSTEXPR static inline Q_DECL_UNUSED bool qIsNull(double d) noexcept
                                                 ^~~~~~~~~~~~~
/usr/local/include/QtCore/qcompilerdetection.h:983:25: note: expanded from macro 'Q_DECL_UNUSED'
#  define Q_DECL_UNUSED [[maybe_unused]]
                        ^~~~~~~~~~~~~~~~
In file included from /Users/arkasantra/geant4-v11.2.1/examples/basic/B1/exampleB1.cc:38:
In file included from /Users/arkasantra/Geant4_Install/include/Geant4/G4VisExecutive.hh:141:
In file included from /Users/arkasantra/Geant4_Install/include/Geant4/G4VisExecutive.icc:142:
In file included from /usr/local/opt/qt@5/lib/QtCore.framework/Headers/QtGlobal:1:
/usr/local/opt/qt@5/lib/QtCore.framework/Headers/qglobal.h:930:50: error: an attribute list cannot appear here
Q_REQUIRED_RESULT Q_DECL_CONSTEXPR static inline Q_DECL_UNUSED bool qIsNull(float f) noexcept
                                                 ^~~~~~~~~~~~~
/usr/local/include/QtCore/qcompilerdetection.h:983:25: note: expanded from macro 'Q_DECL_UNUSED'
#  define Q_DECL_UNUSED [[maybe_unused]]
                        ^~~~~~~~~~~~~~~~
In file included from /Users/arkasantra/geant4-v11.2.1/examples/basic/B1/exampleB1.cc:38:
In file included from /Users/arkasantra/Geant4_Install/include/Geant4/G4VisExecutive.hh:141:
In file included from /Users/arkasantra/Geant4_Install/include/Geant4/G4VisExecutive.icc:142:
In file included from /usr/local/opt/qt@5/lib/QtCore.framework/Headers/QtGlobal:1:
/usr/local/opt/qt@5/lib/QtCore.framework/Headers/qglobal.h:1252:41: error: 'maybe_unused' attribute cannot be applied to types
template <typename... Args> Q_CONSTEXPR Q_DECL_UNUSED QOverload<Args...> qOverload = {};
                                        ^
/usr/local/include/QtCore/qcompilerdetection.h:983:27: note: expanded from macro 'Q_DECL_UNUSED'
#  define Q_DECL_UNUSED [[maybe_unused]]
                          ^
In file included from /Users/arkasantra/geant4-v11.2.1/examples/basic/B1/exampleB1.cc:38:
In file included from /Users/arkasantra/Geant4_Install/include/Geant4/G4VisExecutive.hh:141:
In file included from /Users/arkasantra/Geant4_Install/include/Geant4/G4VisExecutive.icc:142:
In file included from /usr/local/opt/qt@5/lib/QtCore.framework/Headers/QtGlobal:1:
/usr/local/opt/qt@5/lib/QtCore.framework/Headers/qglobal.h:1253:41: error: 'maybe_unused' attribute cannot be applied to types
template <typename... Args> Q_CONSTEXPR Q_DECL_UNUSED QConstOverload<Args...> qConstOverload = {};
                                        ^
/usr/local/include/QtCore/qcompilerdetection.h:983:27: note: expanded from macro 'Q_DECL_UNUSED'
#  define Q_DECL_UNUSED [[maybe_unused]]
                          ^
In file included from /Users/arkasantra/geant4-v11.2.1/examples/basic/B1/exampleB1.cc:38:
In file included from /Users/arkasantra/Geant4_Install/include/Geant4/G4VisExecutive.hh:141:
In file included from /Users/arkasantra/Geant4_Install/include/Geant4/G4VisExecutive.icc:142:
In file included from /usr/local/opt/qt@5/lib/QtCore.framework/Headers/QtGlobal:1:
/usr/local/opt/qt@5/lib/QtCore.framework/Headers/qglobal.h:1254:41: error: 'maybe_unused' attribute cannot be applied to types
template <typename... Args> Q_CONSTEXPR Q_DECL_UNUSED QNonConstOverload<Args...> qNonConstOverload = {};
                                        ^
/usr/local/include/QtCore/qcompilerdetection.h:983:27: note: expanded from macro 'Q_DECL_UNUSED'
#  define Q_DECL_UNUSED [[maybe_unused]]
                          ^
In file included from /Users/arkasantra/geant4-v11.2.1/examples/basic/B1/exampleB1.cc:38:
In file included from /Users/arkasantra/Geant4_Install/include/Geant4/G4VisExecutive.hh:141:
In file included from /Users/arkasantra/Geant4_Install/include/Geant4/G4VisExecutive.icc:142:
In file included from /usr/local/opt/qt@5/lib/QtCore.framework/Headers/QtGlobal:1:
In file included from /usr/local/opt/qt@5/lib/QtCore.framework/Headers/qglobal.h:1301:
In file included from /usr/local/include/QtCore/qtypeinfo.h:9:
In file included from /usr/local/include/QtCore/qcontainerfwd.h:8:
In file included from /usr/local/include/QtCore/qtypes.h:10:
In file included from /usr/local/include/QtCore/qassert.h:9:
In file included from /usr/local/include/QtCore/qtcoreexports.h:9:
/usr/local/include/QtCore/qtdeprecationmarkers.h:333:12: error: redefinition of 'Deprecated_t'
enum class Deprecated_t {};
           ^
/usr/local/opt/qt@5/lib/QtCore.framework/Headers/qglobal.h:398:12: note: previous definition is here
enum class Deprecated_t {};
           ^
In file included from /Users/arkasantra/geant4-v11.2.1/examples/basic/B1/exampleB1.cc:38:
In file included from /Users/arkasantra/Geant4_Install/include/Geant4/G4VisExecutive.hh:141:
In file included from /Users/arkasantra/Geant4_Install/include/Geant4/G4VisExecutive.icc:142:
In file included from /usr/local/opt/qt@5/lib/QtCore.framework/Headers/QtGlobal:1:
In file included from /usr/local/opt/qt@5/lib/QtCore.framework/Headers/qglobal.h:1301:
In file included from /usr/local/include/QtCore/qtypeinfo.h:9:
In file included from /usr/local/include/QtCore/qcontainerfwd.h:8:
In file included from /usr/local/include/QtCore/qtypes.h:10:
In file included from /usr/local/include/QtCore/qassert.h:9:
In file included from /usr/local/include/QtCore/qtcoreexports.h:9:
/usr/local/include/QtCore/qtdeprecationmarkers.h:334:31: error: inline declaration of 'Deprecated' follows non-inline definition
constexpr inline Deprecated_t Deprecated = {};
                              ^
/usr/local/opt/qt@5/lib/QtCore.framework/Headers/qglobal.h:399:38: note: previous definition is here
constexpr Q_DECL_UNUSED Deprecated_t Deprecated = {};
                                     ^
In file included from /Users/arkasantra/geant4-v11.2.1/examples/basic/B1/exampleB1.cc:38:
In file included from /Users/arkasantra/Geant4_Install/include/Geant4/G4VisExecutive.hh:141:
In file included from /Users/arkasantra/Geant4_Install/include/Geant4/G4VisExecutive.icc:142:
In file included from /usr/local/opt/qt@5/lib/QtCore.framework/Headers/QtGlobal:1:
In file included from /usr/local/opt/qt@5/lib/QtCore.framework/Headers/qglobal.h:1301:
In file included from /usr/local/include/QtCore/qtypeinfo.h:9:
In file included from /usr/local/include/QtCore/qcontainerfwd.h:8:
In file included from /usr/local/include/QtCore/qtypes.h:10:
In file included from /usr/local/include/QtCore/qassert.h:9:
In file included from /usr/local/include/QtCore/qtcoreexports.h:9:
/usr/local/include/QtCore/qtdeprecationmarkers.h:334:31: error: redefinition of 'Deprecated'
constexpr inline Deprecated_t Deprecated = {};
                              ^
/usr/local/opt/qt@5/lib/QtCore.framework/Headers/qglobal.h:399:38: note: previous definition is here
constexpr Q_DECL_UNUSED Deprecated_t Deprecated = {};
                                     ^
In file included from /Users/arkasantra/geant4-v11.2.1/examples/basic/B1/exampleB1.cc:38:
In file included from /Users/arkasantra/Geant4_Install/include/Geant4/G4VisExecutive.hh:141:
In file included from /Users/arkasantra/Geant4_Install/include/Geant4/G4VisExecutive.icc:142:
In file included from /usr/local/opt/qt@5/lib/QtCore.framework/Headers/QtGlobal:1:
In file included from /usr/local/opt/qt@5/lib/QtCore.framework/Headers/qglobal.h:1301:
In file included from /usr/local/include/QtCore/qtypeinfo.h:9:
In file included from /usr/local/include/QtCore/qcontainerfwd.h:8:
In file included from /usr/local/include/QtCore/qtypes.h:10:
In file included from /usr/local/include/QtCore/qassert.h:10:
/usr/local/include/QtCore/qtnoop.h:14:13: error: exception specification in declaration does not match previous declaration
inline void qt_noop(void)
            ^
/usr/local/opt/qt@5/lib/QtCore.framework/Headers/qglobal.h:770:13: note: previous declaration is here
inline void qt_noop(void) {}
            ^
In file included from /Users/arkasantra/geant4-v11.2.1/examples/basic/B1/exampleB1.cc:38:
In file included from /Users/arkasantra/Geant4_Install/include/Geant4/G4VisExecutive.hh:141:
In file included from /Users/arkasantra/Geant4_Install/include/Geant4/G4VisExecutive.icc:142:
In file included from /usr/local/opt/qt@5/lib/QtCore.framework/Headers/QtGlobal:1:
In file included from /usr/local/opt/qt@5/lib/QtCore.framework/Headers/qglobal.h:1301:
In file included from /usr/local/include/QtCore/qtypeinfo.h:9:
In file included from /usr/local/include/QtCore/qcontainerfwd.h:8:
In file included from /usr/local/include/QtCore/qtypes.h:10:
/usr/local/include/QtCore/qassert.h:51:1: error: 'noreturn' attribute does not appear on the first declaration
Q_NORETURN Q_DECL_COLD_FUNCTION
^
/usr/local/include/QtCore/qcompilerdetection.h:988:24: note: expanded from macro 'Q_NORETURN'
#  define Q_NORETURN [[noreturn]]
                       ^
/usr/local/opt/qt@5/lib/QtCore.framework/Headers/qglobal.h:879:20: note: previous declaration is here
Q_CORE_EXPORT void qBadAlloc();
                   ^
In file included from /Users/arkasantra/geant4-v11.2.1/examples/basic/B1/exampleB1.cc:38:
In file included from /Users/arkasantra/Geant4_Install/include/Geant4/G4VisExecutive.hh:141:
In file included from /Users/arkasantra/Geant4_Install/include/Geant4/G4VisExecutive.icc:142:
In file included from /usr/local/opt/qt@5/lib/QtCore.framework/Headers/QtGlobal:1:
In file included from /usr/local/opt/qt@5/lib/QtCore.framework/Headers/qglobal.h:1301:
In file included from /usr/local/include/QtCore/qtypeinfo.h:9:
In file included from /usr/local/include/QtCore/qcontainerfwd.h:8:
In file included from /usr/local/include/QtCore/qtypes.h:10:
/usr/local/include/QtCore/qassert.h:65:11: error: redefinition of 'q_check_ptr'
inline T *q_check_ptr(T *p) { Q_CHECK_PTR(p); return p; }
          ^
/usr/local/opt/qt@5/lib/QtCore.framework/Headers/qglobal.h:892:11: note: previous definition is here
inline T *q_check_ptr(T *p) { Q_CHECK_PTR(p); return p; }
          ^
In file included from /Users/arkasantra/geant4-v11.2.1/examples/basic/B1/exampleB1.cc:38:
In file included from /Users/arkasantra/Geant4_Install/include/Geant4/G4VisExecutive.hh:141:
In file included from /Users/arkasantra/Geant4_Install/include/Geant4/G4VisExecutive.icc:142:
In file included from /usr/local/opt/qt@5/lib/QtCore.framework/Headers/QtGlobal:1:
In file included from /usr/local/opt/qt@5/lib/QtCore.framework/Headers/qglobal.h:1301:
In file included from /usr/local/include/QtCore/qtypeinfo.h:9:
In file included from /usr/local/include/QtCore/qcontainerfwd.h:8:
/usr/local/include/QtCore/qtypes.h:201:23: error: redefinition of 'QIntegerForSize<1>'
template <>    struct QIntegerForSize<1> { typedef quint8  Unsigned; typedef qint8  Signed; };
                      ^~~~~~~~~~~~~~~~~~
/usr/local/opt/qt@5/lib/QtCore.framework/Headers/qglobal.h:568:23: note: previous definition is here
template <>    struct QIntegerForSize<1> { typedef quint8  Unsigned; typedef qint8  Signed; };
                      ^
In file included from /Users/arkasantra/geant4-v11.2.1/examples/basic/B1/exampleB1.cc:38:
In file included from /Users/arkasantra/Geant4_Install/include/Geant4/G4VisExecutive.hh:141:
In file included from /Users/arkasantra/Geant4_Install/include/Geant4/G4VisExecutive.icc:142:
In file included from /usr/local/opt/qt@5/lib/QtCore.framework/Headers/QtGlobal:1:
In file included from /usr/local/opt/qt@5/lib/QtCore.framework/Headers/qglobal.h:1301:
In file included from /usr/local/include/QtCore/qtypeinfo.h:9:
In file included from /usr/local/include/QtCore/qcontainerfwd.h:8:
/usr/local/include/QtCore/qtypes.h:202:23: error: redefinition of 'QIntegerForSize<2>'
template <>    struct QIntegerForSize<2> { typedef quint16 Unsigned; typedef qint16 Signed; };
                      ^~~~~~~~~~~~~~~~~~
/usr/local/opt/qt@5/lib/QtCore.framework/Headers/qglobal.h:569:23: note: previous definition is here
template <>    struct QIntegerForSize<2> { typedef quint16 Unsigned; typedef qint16 Signed; };
                      ^
In file included from /Users/arkasantra/geant4-v11.2.1/examples/basic/B1/exampleB1.cc:38:
In file included from /Users/arkasantra/Geant4_Install/include/Geant4/G4VisExecutive.hh:141:
In file included from /Users/arkasantra/Geant4_Install/include/Geant4/G4VisExecutive.icc:142:
In file included from /usr/local/opt/qt@5/lib/QtCore.framework/Headers/QtGlobal:1:
In file included from /usr/local/opt/qt@5/lib/QtCore.framework/Headers/qglobal.h:1301:
In file included from /usr/local/include/QtCore/qtypeinfo.h:9:
In file included from /usr/local/include/QtCore/qcontainerfwd.h:8:
/usr/local/include/QtCore/qtypes.h:203:23: error: redefinition of 'QIntegerForSize<4>'
template <>    struct QIntegerForSize<4> { typedef quint32 Unsigned; typedef qint32 Signed; };
                      ^~~~~~~~~~~~~~~~~~
/usr/local/opt/qt@5/lib/QtCore.framework/Headers/qglobal.h:570:23: note: previous definition is here
template <>    struct QIntegerForSize<4> { typedef quint32 Unsigned; typedef qint32 Signed; };
                      ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[2]: *** [CMakeFiles/exampleB1.dir/exampleB1.cc.o] Error 1
make[1]: *** [CMakeFiles/exampleB1.dir/all] Error 2
make: *** [all] Error 2

Seems again the Qt5 is the problem.
I installed Qt5 using brew.
My system has Qt6 installed as well, but I made sure that in the PATH variable, Qt5 comes before the Qt6:

PATH=/usr/local/opt/openjdk/bin:/usr/local/opt/jpeg/bin:/usr/local/opt/krb5/sbin:/usr/local/opt/krb5/bin:/usr/local/opt/qt@5/bin:/usr/local/opt/qt/bin:/opt/anaconda3/bin:/opt/anaconda3/condabin:/usr/local/opt/gnu-getopt/bin

May I know how I should solve this problem?
I am using CMAKE_CXX_STANDARD=20 , will this be a problem?

Thank you once again,
Arka

Unfortunately, the only way to build with Homebrew qt@5 if you have qt (i.e., Qt6) installed is to unlink the qt Formula. Its headers will otherwise be picked up before those of the qt@5 formula, leading to the above error. The PATH and C++ standard have no impact on this behaviour as it’s related to compiler header search paths.

Unlinking qt is usually safe unless you’re actively relying on it for other projects.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.