Problem 2202

Summary: g4py build fails when PREFIX is used <boost/python.hpp>
Product: Environments Reporter: Ligia Diana Pinto de Almeida Amorim <LDianaAmorim>
Component: g4pyAssignee: Koichi Murakami <Koichi.Murakami>
Status: CLOSED FIXED    
Severity: normal CC: axelhuebl
Priority: P4    
Version: 2.0   
Hardware: Apple   
OS: Mac OS X   

Description Ligia Diana Pinto de Almeida Amorim 2019-11-13 21:56:25 CET
Hi,

I am new to Geant4 and wish to install its python G4py version.
I tried to follow the instructions that I found online for installing both on MacOS High Sierra (clang and anaconda3).

Initially, I came across an issue when I make G4py, which starts with:

[  0%] Building CXX object source/intercoms/CMakeFiles/pyG4intercoms.dir/pyG4UIcommand.cc.o
/Users/diana/Documents/opt/geant4/environments/g4py/source/intercoms/pyG4UIcommand.cc/Users/diana/Documents/opt/geant4/environments/g4py/source/interface/pyG4UIterminal.cc::3131::1010::  fatal errorfatal error: : 'boost/python.hpp' file not found
'boost/python.hpp' file not found
#include <boost/python.hpp>
         ^~~~~~~~~~~~~~~~~~
#include <boost/python.hpp>
         ^~~~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [source/intercoms/CMakeFiles/pyG4intercoms.dir/pyG4UIcommand.cc.o] Error 1

Which I reported in the forum https://geant4-forum.web.cern.ch/t/error-with-python-hpp-for-macos-clang-anaconda3/1256.

At that time, I was using the following commands to install Geant4 and g4py:

# Geant4
git clone https://gitlab.cern.ch/geant4/geant4.git
cd geant4
GEANT4_DIR=/Users/diana/Documents/opt/geant4
GEANT4_INSTALL=$GEANT4_DIR/geant4-install
mkdir $GEANT4_INSTALL
GEANT4_BUILD=$GEANT4_DIR/geant4-build
mkdir $GEANT4_BUILD
cd $GEANT4_BUILD
cmake -DCMAKE_INSTALL_PREFIX=$GEANT4_INSTALL -DGEANT4_USE_OPENGL_X11=ON $GEANT4_BUILD
make -j 4
make install

# Python interface of Geant4
export GEANT4_INSTALL=/Users/diana/Documents/opt/geant4/geant4-install
cd ../environments/g4py/
mkdir build
cd build
BOOST_DIR=/anaconda3/pkgs/libboost-1.67.0-hebc422b_4
XERCESC_DIR=/anaconda3/pkgs/xerces-c-3.2.2-h4db8090_1003
BOOST_ROOT=$BOOST_DIR
cmake -DBOOST_ROOT=$BOOST_DIR -DBoost_INCLUDE_DIR=$BOOST_DIR/include -DBOOST_LIBRARY=$BOOST_DIR/lib -DXERCESC_INCLUDE_DIR=$XERCESC_DIR/include -DXERCESC_LIBRARY=$XERCESC_DIR/lib ..
make -j 4
(when the error mentioned above occurs)


Have you ever encountered this issue before? Do you have any recommendation on how to fix it?


Recently, I found a work-around for this issue that involves not setting any paths for the cmake command.
So right now I just follow the commands below:

# Geant4
git clone https://gitlab.cern.ch/geant4/geant4.git
cd geant4
mkdir build
cd build
cmake  -DGEANT4_USE_OPENGL_X11=ON $GEANT4_BUILD
make -j 4
make install

# g4py
cd ../environments/g4py/
mkdir build
cd build
cmake ..
make -j 4
(when a new error reported in https://bugzilla-geant4.kek.jp/show_bug.cgi?id=2201 occurs)

My environment is:

*Environment:*
- MacOS High Sierra
- clang 10.0.0
- conda 4.7.12
- cmake 3.15.5
- XQuartz 2.7.11
- python 3.7.5
- boost 1.67.0 
- xerces-c 3.2.2

I decided to post this here in case you knew how to fix the issue or if this is the best work-around for it.
Comment 1 Koichi Murakami 2020-04-22 09:59:09 CEST
find package of cmake takes care for the path setting. In most case, you do not have to specify _INCLUDE path, etc. The workaround is in the right way.