Search code examples
makefilecmaketarget

Geant4, example B1 build error: no rule to make target


I'm trying to compile the B1 example for Geant4-10.0.1. This link provides instructions http://geant4.web.cern.ch/geant4/UserDocumentation/UsersGuides/InstallationGuide/html/ch03s02.html

I have two separate dir: B1 and B1-build. Everything is normal up until

$ make -jN

I get the following error

$ make -j4
Scanning dependencies of target exampleB1
[ 12%] [ 37%] [ 37%] [ 50%] Building CXX object CMakeFiles/exampleB1.dir/src/B1Run.cc.o
Building CXX object CMakeFiles/exampleB1.dir/src/B1PrimaryGeneratorAction.cc.o
Building CXX object CMakeFiles/exampleB1.dir/exampleB1.cc.o
Building CXX object CMakeFiles/exampleB1.dir/src/B1EventAction.cc.o
[ 62%] Building CXX object CMakeFiles/exampleB1.dir/src/B1RunAction.cc.o
[ 75%] Building CXX object CMakeFiles/exampleB1.dir/src/B1DetectorConstruction.cc.o
[ 87%] Building CXX object CMakeFiles/exampleB1.dir/src/B1ActionInitialization.cc.o
[100%] make[2]: *** No rule to make target '/usr/lib64/libexpat.so', needed by 'exampleB1'.  Stop.
make[2]: *** Waiting for unfinished jobs....
Building CXX object CMakeFiles/exampleB1.dir/src/B1SteppingAction.cc.o
CMakeFiles/Makefile2:94: recipe for target 'CMakeFiles/exampleB1.dir/all' failed
make[1]: *** [CMakeFiles/exampleB1.dir/all] Error 2
Makefile:116: recipe for target 'all' failed
make: *** [all] Error 2

Any ideas? Thanks.

--Edit--

After trying

$ make VERBOSE=1

it ended with a similar error message:

.
.
.
[100%] Building CXX object CMakeFiles/exampleB1.dir/src/B1SteppingAction.cc.o
/usr/bin/c++   -DG4UI_USE -DG4UI_USE_TCSH -DG4VERBOSE -DG4VIS_USE -DG4_STORE_TRAJECTORY -W -Wall -pedantic -Wno-non-virtual-dtor -Wno-long-long -Wwrite-strings -Wpointer-arith -Woverloaded-virtual -Wno-variadic-macros -Wshadow -pipe -std=c++98 -I/usr/local/geant4.10.00.p01-install/include/Geant4 -I/1/home/walterms/geant4builds/B1/include    -o CMakeFiles/exampleB1.dir/src/B1SteppingAction.cc.o -c /1/home/walterms/geant4builds/B1/src/B1SteppingAction.cc
make[2]: *** No rule to make target '/usr/lib64/libexpat.so', needed by 'exampleB1'.  Stop.
make[2]: Leaving directory '/1/home/walterms/geant4builds/B1-build'
CMakeFiles/Makefile2:94: recipe for target 'CMakeFiles/exampleB1.dir/all' failed
make[1]: *** [CMakeFiles/exampleB1.dir/all] Error 2
make[1]: Leaving directory '/1/home/walterms/geant4builds/B1-build'
Makefile:116: recipe for target 'all' failed
make: *** [all] Error 2

Still lost.


Solution

  • I managed to build the B1 example you refer to after installing the library.

    I extracted geant4.10.00.p01.tar.gz.

    then

    mkdir build && cd build && \
    cmake -DCMAKE_INSTALL_PREFIX=../geant4-install ../geant4.10.00.p01 && \
    make -j8 && make install
    

    Then I executed

    source ./geant4.sh
    

    in geant4-install/bin.

    I build the B1 sample as follows:

    cd geant4.10.00.p01/examples/basic/B1 && \
    mkdir build && cd build && cmake ../ && make
    

    This built and linked the example.

    Again .. do you have libexpat installed? /usr/lib64/libexpat.so points to a valid shared library?