Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Are these bindings supposed to work with the Geant4 conda-forge package? #13

Open
HealthyPear opened this issue Mar 1, 2023 · 3 comments

Comments

@HealthyPear
Copy link

The installation went fine, but the example usage failed,

In [1]: from geant4_pybind import G4UIExecutive
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[1], line 1
----> 1 from geant4_pybind import G4UIExecutive

ImportError: dlopen(/Users/michele/Applications/mambaforge/envs/geant4/lib/python3.11/site-packages/geant4_pybind.cpython-311-darwin.so, 2): Symbol not found: __ZTTNSt3__114basic_ofstreamIcNS_11char_traitsIcEEEE
  Referenced from: /Users/michele/Applications/mambaforge/envs/geant4/lib/python3.11/site-packages/geant4_pybind.cpython-311-darwin.so
  Expected in: /usr/lib/libc++.1.dylib
 in /Users/michele/Applications/mambaforge/envs/geant4/lib/python3.11/site-packages/geant4_pybind.cpython-311-darwin.so

I put here some info about my installation of Geant4 using geant4-config to help the debug,

Known Features:
 staticlibs[no]
 multithreading[yes]
 smartstack[no]
 php_as_hp[no]
 clhep[no]
 expat[no]
 zlib[no]
 gdml[yes]
 ptl[yes]
 usolids[no]
 freetype[yes]
 hdf5[no]
 g3tog4[no]
 qt[yes]
 motif[no]
 raytracer-x11[no]
 opengl-x11[no]
 openinventor[no]
Key Value
cxxstd 17
tls-model global-dynamic
cflags -DG4VIS_USE_OPENGL -DG4UI_USE_TCSH -DG4UI_USE_QT -DG4VIS_USE_OPENGLQT -I/Users/michele/Applications/mambaforge/envs/geant4/include/qt/ -I/Users/michele/Applications/mambaforge/envs/geant4/include/qt/QtCore -I/Users/michele/Applications/mambaforge/envs/geant4/.//mkspecs/macx-clang -I/Users/michele/Applications/mambaforge/envs/geant4/include/qt/QtGui -I/Applications/Xcode_13.2.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Users/michele/Applications/mambaforge/envs/geant4/include/qt/QtWidgets -I/Users/michele/Applications/mambaforge/envs/geant4/include/qt/QtOpenGL -I/Users/michele/Applications/mambaforge/envs/geant4/include/qt/QtPrintSupport -I/Users/michele/Applications/mambaforge/envs/geant4/include/qt/Qt3DCore -I/Users/michele/Applications/mambaforge/envs/geant4/include/qt/QtNetwork -I/Users/michele/Applications/mambaforge/envs/geant4/include/qt/Qt3DExtras -I/Users/michele/Applications/mambaforge/envs/geant4/include/qt/Qt3DRender -I/Users/michele/Applications/mambaforge/envs/geant4/include/qt/Qt3DInput -I/Users/michele/Applications/mambaforge/envs/geant4/include/qt/QtGamepad -I/Users/michele/Applications/mambaforge/envs/geant4/include/qt/Qt3DLogic -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -fmessage-length=0 -isystem /Users/michele/Applications/mambaforge/envs/geant4/include -fdebug-prefix-map=/Users/runner/miniforge3/conda-bld/geant4_1667500347678/work=/usr/local/src/conda/geant4-11.0.3 -fdebug-prefix-map=/Users/michele/Applications/mambaforge/envs/geant4=/usr/local/src/conda-prefix -D_LIBCPP_DISABLE_AVAILABILITY -W -Wall -pedantic -Wno-non-virtual-dtor -Wno-long-long -Wwrite-strings -Wpointer-arith -Woverloaded-virtual -Wno-variadic-macros -Wshadow -pipe -Qunused-arguments -DGL_SILENCE_DEPRECATION -pthread -ftls-model=global-dynamic -std=c++17 -I/Users/michele/Applications/mambaforge/envs/geant4/bin/../include/Geant4 -I/Users/michele/Applications/mambaforge/envs/geant4/include -I/Users/michele/Applications/mambaforge/envs/geant4/include
@HaarigerHarald
Copy link
Owner

HaarigerHarald commented Mar 1, 2023

No idea about Macs and OS X but this came up when I googled your error:
https://stackoverflow.com/questions/71174306/expected-in-usr-lib-libc-1-dylib-installing-tensorflow-on-m1-macbook-pro

Might be some architecture or OSX version mismatch

@shayan0373n
Copy link

shayan0373n commented Jan 23, 2024

I tried to build & install geant4_pybind for the Geant4 package installed via conda-forge on macOS 14.3. The Geant4 package is built with the GEANT4_BUILD_TLS_MODEL=global-dynamic option set.

After installing Geant4 via conda-forge, I also had to install zlib, xerces-c, and freetype packages using Homebrew to avoid build process failures. Furthermore, I also had to run export CMAKE_PREFIX_PATH=/usr/local/opt/zlib so that CMake could locate the correct zlib package. After these, the build process went through successfully.

However, when I try to run an example, I get segmentation fault.

The output of python -X faulthandler exampleB2a.py is:

Available UI session types: [ Qt, tcsh, csh ]

**********************************************************
 Geant4 version Name: geant4-11-01-patch-03 [MT]   (10-November-2023)
                       Copyright : Geant4 Collaboration
                      References : NIM A 506 (2003), 250-303
                                 : IEEE-TNS 53 (2006), 270-278
                                 : NIM A 835 (2016), 186-225
                             WWW : http://geant4.org/
**********************************************************

<<< Geant4 Physics List simulation engine: FTFP_BERT

Visualization Manager instantiating with verbosity "warnings (3)"...
Visualization Manager initialising...
Registering graphics systems...

You have successfully registered the following graphics systems.
Registered graphics systems are:
  ASCIITree (ATree)
  DAWNFILE (DAWNFILE)
  G4HepRepFile (HepRepFile)
  RayTracer (RayTracer)
  VRML2FILE (VRML2FILE)
  gMocrenFile (gMocrenFile)
  TOOLSSG_OFFSCREEN (TSG_OFFSCREEN)
  TOOLSSG_OFFSCREEN (TSG_OFFSCREEN, TSG_FILE)
  OpenGLImmediateQt (OGLIQt, OGLI)
  OpenGLStoredQt (OGLSQt, OGL, OGLS)
  Qt3D (Qt3D)

Registering model factories...

You have successfully registered the following model factories.
Registered model factories:
  generic
  drawByAttribute
  drawByCharge
  drawByOriginVolume
  drawByParticleID
  drawByEncounteredVolume

Registered models:
  None

Registered filter factories:
  attributeFilter
  chargeFilter
  originVolumeFilter
  particleFilter
  encounteredVolumeFilter

Registered filters:
  None

You have successfully registered the following user vis actions.
Run Duration User Vis Actions: none
End of Event User Vis Actions: none
End of Run User Vis Actions: none

Some /vis commands (optionally) take a string to specify colour.
"/vis/list" to see available colours.
/control/saveHistory
/run/verbose 2
#
# Change the default number of threads (in multi-threaded mode)
#/run/numberOfThreads 4
#
# Initialize kernel
/run/initialize
userDetector->Construct() start.
Fatal Python error: Segmentation fault

Current thread 0x00007ff846de57c0 (most recent call first):
  File "/Users/tara/Library/CloudStorage/[email protected]/My Drive/Muon/Dec 18th/examples/B2/exampleB2a.py", line 150 in DefineMaterials
  File "/Users/tara/Library/CloudStorage/[email protected]/My Drive/Muon/Dec 18th/examples/B2/exampleB2a.py", line 295 in Construct
  File "/Users/tara/Library/CloudStorage/[email protected]/My Drive/Muon/Dec 18th/examples/B2/exampleB2a.py", line 464 in <module>
zsh: segmentation fault  python -X faulthandler exampleB2a.py

Do you have any idea what might have gone wrong here?

Edit: I should add that I can install the package via pip and run examples without a problem. The above issue only happens after installing from source.

@HaarigerHarald
Copy link
Owner

I'm not sure how conda works on MacOS, but it might be that the conda geant4 package was linked against a c/c++ library shipped with conda while the packages you installed with hombrew are linked against the system c/c++ library. Might be worth trying out whether you can install those additional packages via conda-forge instead. Also make sure you are in the conda environment when building the bindings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants