Make --> fatal error: Xm/Xm.h

I am currently setting up Geant4 for BDSIM on my Ubuntu system (Windows subsystem). For this the version Geant4.10.4.p03 is suggested and the cmake properties are set as in

The configuring and generating with those properties works just fine, just a few warnings:


CMake Warning at cmake/Modules/G4DeveloperAPI_OLD.cmake:297 (add_library):
Cannot generate a safe runtime search path for target G4interfaces because
files in some directories may conflict with libraries in implicit
directories:

runtime library [libQt5PrintSupport.so.5] in /home/fstummer/anaconda3/lib
may be hidden by files in:
/usr/lib/x86_64-linux-gnu
runtime library [libSM.so.6] in /home/fstummer/anaconda3/lib may be hidden
by files in:
/usr/lib/x86_64-linux-gnu
runtime library [libICE.so.6] in /home/fstummer/anaconda3/lib may be hidden
by files in:
/usr/lib/x86_64-linux-gnu
runtime library [libX11.so.6] in /home/fstummer/anaconda3/lib may be hidden
by files in:
/usr/lib/x86_64-linux-gnu
runtime library [libXext.so.6] in /home/fstummer/anaconda3/lib may be hidden
by files in:
/usr/lib/x86_64-linux-gnu
runtime library [libXt.so.6] in /home/fstummer/anaconda3/lib may be hidden
by files in:
/usr/lib/x86_64-linux-gnu
runtime library [libXmu.so] in /home/fstummer/anaconda3/lib may be hidden by
files in:
/usr/lib/x86_64-linux-gnu
runtime library [libQt5Widgets.so.5] in /home/fstummer/anaconda3/lib may be
hidden by files in:
/usr/lib/x86_64-linux-gnu
runtime library [libQt5Gui.so.5] in /home/fstummer/anaconda3/lib may be
hidden by files in:
/usr/lib/x86_64-linux-gnu
runtime library [libQt5Core.so.5] in /home/fstummer/anaconda3/lib may be
hidden by files in:
/usr/lib/x86_64-linux-gnu

Some of these libraries may not be found correctly.
Call Stack (most recent call first):
cmake/Modules/G4DeveloperAPI_OLD.cmake:499 (geant4_library_target)
source/interfaces/CMakeLists.txt:21 (GEANT4_GLOBAL_LIBRARY_TARGET)

CMake Warning at cmake/Modules/G4DeveloperAPI_OLD.cmake:297 (add_library):
Cannot generate a safe runtime search path for target G4OpenGL because
files in some directories may conflict with libraries in implicit
directories:

runtime library [libSM.so.6] in /home/fstummer/anaconda3/lib may be hidden
by files in:
/usr/lib/x86_64-linux-gnu
runtime library [libICE.so.6] in /home/fstummer/anaconda3/lib may be hidden
by files in:
/usr/lib/x86_64-linux-gnu
runtime library [libX11.so.6] in /home/fstummer/anaconda3/lib may be hidden
by files in:
/usr/lib/x86_64-linux-gnu
runtime library [libXext.so.6] in /home/fstummer/anaconda3/lib may be hidden
by files in:
/usr/lib/x86_64-linux-gnu
runtime library [libXt.so.6] in /home/fstummer/anaconda3/lib may be hidden
by files in:
/usr/lib/x86_64-linux-gnu
runtime library [libXmu.so] in /home/fstummer/anaconda3/lib may be hidden by
files in:
/usr/lib/x86_64-linux-gnu
runtime library [libQt5OpenGL.so.5] in /home/fstummer/anaconda3/lib may be
hidden by files in:
/usr/lib/x86_64-linux-gnu
runtime library [libQt5PrintSupport.so.5] in /home/fstummer/anaconda3/lib
may be hidden by files in:
/usr/lib/x86_64-linux-gnu
runtime library [libQt5Widgets.so.5] in /home/fstummer/anaconda3/lib may be
hidden by files in:
/usr/lib/x86_64-linux-gnu
runtime library [libQt5PrintSupport.so.5] in /home/fstummer/anaconda3/lib
may be hidden by files in:
/usr/lib/x86_64-linux-gnu
runtime library [libQt5Widgets.so.5] in /home/fstummer/anaconda3/lib may be
hidden by files in:
/usr/lib/x86_64-linux-gnu
runtime library [libfreetype.so.6] in /home/fstummer/anaconda3/lib may be
hidden by files in:
/usr/lib/x86_64-linux-gnu
runtime library [libexpat.so.1] in /home/fstummer/anaconda3/lib may be
hidden by files in:
/usr/lib/x86_64-linux-gnu
runtime library [libQt5Gui.so.5] in /home/fstummer/anaconda3/lib may be
hidden by files in:
/usr/lib/x86_64-linux-gnu
runtime library [libQt5Core.so.5] in /home/fstummer/anaconda3/lib may be
hidden by files in:
/usr/lib/x86_64-linux-gnu

Some of these libraries may not be found correctly.
Call Stack (most recent call first):
cmake/Modules/G4DeveloperAPI_OLD.cmake:499 (geant4_library_target)
source/visualization/OpenGL/CMakeLists.txt:18 (GEANT4_GLOBAL_LIBRARY_TARGET)


Anaconda is installed, which is why the files are sometimes found twice in different folders.
I used the following gcc and cmake versions:
gcc (crosstool-NG 1.24.0.131_87df0e6_dirty) 7.5.0
cmake version 3.16.3

When I run make, after 81% are finished, I get the following error:


[ 81%] Building CXX object source/interfaces/CMakeFiles/G4interfaces.dir/basic/src/G4UIXm.cc.o
/home/fstummer/geant4.10.04.p03/source/interfaces/basic/src/G4UIXm.cc:43:10: fatal error: Xm/Xm.h: No such file or directory
#include <Xm/Xm.h>
^~~~~~~~~
compilation terminated.
make[2]: *** [source/interfaces/CMakeFiles/G4interfaces.dir/build.make:197: source/interfaces/CMakeFiles/G4interfaces.dir/basic/src/G4UIXm.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:4226: source/interfaces/CMakeFiles/G4interfaces.dir/all] Error 2
make: *** [Makefile:152: all] Error 2


In the Geant4-Installation guide I found that this header needs to be in MOTIF_INCLUDE_DIR, which is set to /usr/include and Xm/Xm.h is actually there. The following lines show how motif and opengl variables are set right now:


GEANT4_USE_XM ON
MOTIF_INCLUDE_DIR /usr/include
MOTIF_LIBRARIES /usr/lib/x86_64-linux-gnu/libXm.so
OPENGL_EGL_INCLUDE_DIR /usr/include
OPENGL_GLX_INCLUDE_DIR /usr/include
OPENGL_INCLUDE_DIR /usr/include
OPENGL_egl_LIBRARY /usr/lib/x86_64-linux-gnu/libEGL.so
OPENGL_gl_LIBRARY /usr/lib/x86_64-linux-gnu/libGL.so
OPENGL_glu_LIBRARY /usr/lib/x86_64-linux-gnu/libGLU.so
OPENGL_glx_LIBRARY /usr/lib/x86_64-linux-gnu/libGLX.so
OPENGL_opengl_LIBRARY /usr/lib/x86_64-linux-gnu/libOpenGL.so
OPENGL_xmesa_INCLUDE_DIR


What can I do about this error?

I’ve not tried or seen builds with this setup before, so am not sure I can give a good answer. You can try running make VERBOSE=1 which will output the full command used to compile G4UIXm.cc that should show the exact include paths used. Given that the anaconda compiler is being used, it might be ignoring the system path, though given MOTIF_INCLUDE_DIR is set I’m not sure.

Perhaps also contact the BDSIM developers to see if they have experience with this setup.

Yes, it seems there was something mixed up with the paths because of anaconda3. I removed anaconda3 from the system and the correct libraries were found. This solved the problem for me.

Thank you for helping out!