Compile Geant4 from conda environment

cmake -DCMAKE_INSTALL_PREFIX=$HOME/source_install/Geant4/geant-4-10.7.0 \
-DCMAKE_BUILD_TYPE=Debug \
-DBUILD_SHARED_LIBS=ON \
-DGEANT4_BUILD_CXXSTD=17 \
-DGEANT4_USE_FREETYPE=ON \
-DGEANT4_USE_QT=ON \
-DGEANT4_USE_OPENGL_X11=ON \
-DGEANT4_INSTALL_DATA=ON \
-DGEANT4_USE_RAYTRACER_X11=ON \
-DGEANT4_USE_GDML=ON \
-DGEANT4_USE_SYSTEM_CLHEP=ON \
-DCLHEP_INCLUDE_DIR=$HOME/source_install/Geant4/CLHEP/include \
-DCLHEP_LIBRARY=$HOME/source_install/Geant4/CLHEP/lib/libCLHEP.so \
-DGEANT4_INSTALL_EXAMPLES=ON \
-DGEANT4_USE_PYTHON=ON \
-DGEANT4_BUILD_MULTITHREADED=ON \
-DGEANT4_BUILD_TLS_MODEL=global-dynamic \
-DGEANT4_USE_SYSTEM_EXPAT=ON \
-DGEANT4_USE_SYSTEM_ZLIB=ON \
..

I am trying to compile it from conda environment(for Qt5) but it throws several warning, e.g

runtime library [libexpat.so.1] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /home/pranto/miniconda3/envs/geant4/lib
    runtime library [libfreetype.so.6] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /home/pranto/miniconda3/envs/geant4/lib
    runtime library [libz.so.1] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /home/pranto/miniconda3/envs/geant4/lib

although those libraries are found on root file which actually I want

-- Found EXPAT: /usr/lib/x86_64-linux-gnu/libexpat.so (found version "2.2.9") 
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.11") 
-- Found XercesC: /usr/lib/x86_64-linux-gnu/libxerces-c.so (found version "3.2.3") 
-- Found Freetype: /usr/lib/x86_64-linux-gnu/libfreetype.so (found version "2.10.2") 
-- Found OpenGL: /usr/lib/x86_64-linux-gnu/libOpenGL.so   
-- Found X11: /usr/include   
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so - found

I have also tried to install run time library into my conda environment

conda install -c conda-forge expat freetype xerces-c xorg-libx11 xorg-libxfixes xorg-libxmu

But still same error.
Is it possible to pass additional cmake arguments to take run time library from root file rather than conda lib?

Hi all,

I have solved this problem.

Could you add some details on how you solved it?

Future readers with a similar issue who find this post will thank you :wink:

@php1ic Sorry for the late reply.

Dependency Install

$ conda create -n geant4
$ conda activate geant4
$ conda config --add channels conda-forge
$ conda install make \
	cmake \
	compilers \
	sed \
	mesa-libgl-devel-cos6-x86_64 \
	mesa-dri-drivers-cos6-x86_64 \
	libselinux-cos6-x86_64 \
	libxdamage-cos6-x86_64 \
	libxxf86vm-cos6-x86_64 \
	python=3.9 \
	boost=1.72.0 \
	clhep=2.4.4.0 \
	expat \
	freetype \
	libglu \
	qt=5.12 \
	xerces-c \
	xorg-libx11 \
	xorg-libxfixes \
	xorg-libxmu \
	zlib \
	xorg-libxfixes \
	libxext-cos6-x86_64

Compile

$ cmake .. \
	-DCMAKE_BUILD_TYPE=Debug \
	-DCMAKE_INSTALL_PREFIX=Install path location \
	-DBUILD_SHARED_LIBS=ON \
	-DGEANT4_BUILD_CXXSTD=17 \
	-DGEANT4_BUILD_MULTITHREADED=ON \
	-DGEANT4_BUILD_TLS_MODEL=global-dynamic \
	-DGEANT4_INSTALL_DATA=ON \
	-DGEANT4_INSTALL_DATASETS_TENDL=ON \
	-DGEANT4_INSTALL_DATA_TIMEOUT=3000 \
	-DGEANT4_INSTALL_EXAMPLES=ON \
	-DGEANT4_USE_FREETYPE=ON \
	-DGEANT4_USE_GDML=ON \
	-DGEANT4_USE_QT=ON \
	-DGEANT4_USE_QT3D=ON \
	-DGEANT4_USE_SYSTEM_CLHEP=ON \
	-DGEANT4_USE_SYSTEM_EXPAT=ON \
	-DGEANT4_USE_SYSTEM_ZLIB=ON \
	-DGEANT4_USE_PYTHON=ON \
	-DGEANT4_USE_OPENGL_X11=ON \
	-DGEANT4_USE_RAYTRACER_X11=ON
$ make -j 16
$ make install

In .zshrc/.bashrc/

export GEANT4_INSTALL=<Geant4 install path>
# Geant4 install path is the path specified by "CMAKE_INSTALL_PREFIX" when building Geant4

@php1ic @bmorgan I want to install geant4-v_10.7.0 from conda-forge. Is it available now?

OK, currently it’s not available from conda-forge channel but a PR geant4 v10.7.0 is on the way.

Thanks for the cmake options and the conda install EVERYTHING_needed. It helps me a lot. Then a remark to say that I had an old conda installation. It was not possible to install this even after creating the “geant4” environment with python3.9. I had to re-install a fresh anaconda to be able to compile Geant4 10.7.p01. Apart from these everything went fine. It could help others. On more recent machine a conda update was sufficient before creating the geant4 environment, but not for “too old” anaconda installation (like started at python3.7 and updated not regularly).