G01ActionInitialization.o

Hi. I am trying to install example G01. I cmaked and built the project with -DGEANT4_USE_GDML=ON and -DXERCESC_ROOT_DIR=

When I tried ‘make’ with (G4SYSTEM=WIN32-VC) on the build folder, I get

make (e=2): The system cannot find the file specified.
make: *** [./_CPack_Packages/win64/NSIS/Geant4-10.7.2-Windows/Development/share/Geant4-10.7.2/geant4make/config/common.gmk:79: ./_CPack_Packages/win64/NSIS/Geant4-10.7.2-Windows/Development/share/Geant4-10.7.2/geant4make/tmp/WIN32-VC/load_gdml/G01ActionInitialization.o] Error 2

I looked at my folder structure. There doesn’t appear to be a tmp folder. Any idea what could be wrong here?

1 Like

How was CMake called for the example, and what are the paths to the source and build directories? CMake on Windows shouldn’t be generating Makefiles by default, and it looks like this is using the unsupported GNUmakefile located in the source directory for the example.

I’m also a bit confused by the paths it’s looking in. How did you install Geant4 (from a binary installer, or by building from source?) and where is it install on the system?

Edit: Building examples on Windows with CMake is covered in the Application Developer Guide

Hi Benjamin,

And thanks for the quick response. I am actually using the directions for example G01 provided by Gabriele here:

The readme says to do a gmake. I’m not quite sure what setting G4LIB_BUILD_GDML in the environment means. I tried -DG4LIB_BUILD_GDML=1 but that only results in

Manually-specified variables were not used by the project:

G4LIB_BUILD_GDML

in the Geant4 build folder and linking errors in the G01 build folder.

1 Like

But as for Geant4, I built from source. My paths are as follows:

.\geant4_10_07_p02
.\Geant4 (build folder)
.\G01
.\G01Build
…\XERCESCROOT

For cmake I used (in Geant4)
cmake …\geant4_10_07_p02 . -DGEANT4_USE_GDML=ON -DG4LIB_BUILD_GDML=1 -DGEANT4_INSTALL_DATA=ON -DXercesC_LIBRARY=.\XERCESCROOT\src\xercesc\lib -DXercesC_INCLUDE_DIR=…\XERCESCROOT\src\xercesc -DXercesC_VERSION=3.2.3

Then
cmake --build . --config Release

I know I only need to set prefix but that didn’t always work for me.

And in G01_Build the same but …\G01 as the make target. I also copied all the files from G01 over to G01_Build so effectively this is the same as ‘cmake .’
I then used ‘make,’ which I got GNUmake by downloading from Powershell
make G4SYSTEM=WIN32-VC

I don’t know why but doesn’t look like the binary is generated after ‘cmake . --build’ and ‘make’ seems to just fail to complete due to the problem with G01ActionInitialization.o not being created.

I see G01ActionInitialization.hh in the folder but that doesn’t look to be compiling.

O.k., apologies, that README is very out of date… Your install of Geant4 looks o.k, though you should only need the -DGEANT4_USE_GDML=ON flag, and adding -DCMAKE_PREFIX_PATH=...\XERCESCROOT\src (assuming the headers and libs are under that path). However, don’t worry about this if your install of Geant4 is functional.

To build G01 in your above setup, go into G01_Build and delete all the files there (it’s the copying of the GNUmakefile that’s causing the issue). Then, in G01_Build, try running:

cmake -DGeant4_DIR=..\Geant4 ..\G01

this should configure the example - I think the relative paths will work on Windows, but if not, just substitute ..\ with the full paths to these locations. Once that’s all successful, in G01_build again do

cmake --build . --config Release

This should build the executable, and place it in a subdirectory of G01_Build named Release. It can then be run from G01_build as .\Release\load_gdml, but, you will need to set the environment variables for the data libraries first, as documented here: Postinstall Setup — Geant4 Installation Guide 10.7 documentation. For the build in this case, the data will have been downloaded and unpacked under the Geant4 build directory, and should be present there under a data subdirectory, so adjust the paths as needed.

Looks like there’s a bit of problem with using CMAKE_PREFIX_PATH. I tried setting that to both …\XERCESCROOT\src and …\XERCESCROOT\src\xercesc,

cmake .\G01 . -DGeant4_DIR=.\Geant4 -DCMAKE_PREFIX_PATH=…\XERCESCROOT\src\
cmake .\G01 . -DGeant4_DIR=.\Geant4 -DCMAKE_PREFIX_PATH=…\XERCESCROOT\src\xercesc

cmake still expected XercesC_LIBRARY and XercesC_VERSION to be set

CMake Error at C:/Program Files/CMake/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Failed to find XercesC (missing: XercesC_LIBRARY XercesC_VERSION) (Required
is at least version “3.2.3”)


Furthermore, after cmake --build . , I get the error
.\geant4_10_07_p02\source\persistency\gdml\include\G4GDMLRead.hh(37,10): fatal error C1
083: Cannot open include file: ‘/xercesc/parsers/XercesDOMParser.hpp’: No such file or directory [.\G01_Build\load_gdml.vcxproj]

I looked at G4GDMLRead.hh, looks like the #includes here don’t even have a relative path XercesDOMParser.hpp. Is that correct?

#include <xercesc/parsers/XercesDOMParser.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/sax/HandlerBase.hpp>
#include <xercesc/util/XMLUni.hpp>
#include <xercesc/dom/DOM.hpp>

I would double check all the paths you provide. is it literally ...\XERCESROOT with 3 dots? https://devblogs.microsoft.com/oldnewthing/20160202-00/?p=92953

XERCESROOT also suspiciously looks like a placeholder where you should instead put the correct path info, e.g., C:\Users\siygu\Documents\Research\xercesc (or whatever location you installed it to).

Nah. This is right. Somehow when I put 2 ., this shows up as … on here

Like right now …

fyi, this is the cmake command that I use (in windows powershell) to install geant with gdml and qt:

$version = "10_07_p02"
$destination = "C:\Users\me\Geant4\geant4_$($version)"
$CMAKE_PREFIX_PATH = "C:\Qt\5.15.2\msvc2019_64;C:\Users\me\xerces-c\xerces-c-3.2.3"

cd "geant4_$($version)-build"
cmake.exe -DCMAKE_INSTALL_PREFIX="$($destination)\geant4_$($version)-install" `
          -DGEANT4_BUILD_MULTITHREADED=ON `
		  -DCMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH `
		  -DGEANT4_USE_GDML=ON `
		  -DGEANT4_USE_QT=ON `
		  -DGEANT4_INSTALL_DATA=OFF `
		  -DGEANT4_BUILD_MSVC_MP=ON `
		  -DGEANT4_INSTALL_DATADIR="$($destination)\data" `
		  "$($destination)\geant4_$($version)-source"

cmake --build . -j 5 --config Release --target install

and for comparison: the folder C:\Users\me\xerces-c\xerces-c-3.2.3 contains subfolders bin, cmake, include, lib and share

Yeah sorry. I MEANT -DCMAKE_PREFIX_PATH.

And yes,…\XERCESCROOT\src\xercesc is the place where the folders

I still had to set -DXercesC_INCLUDE_DIR=…\XERCESCROOT\src\xercesc -DXercesC_VERSION=3.2.3

But I’m not getting problems here as so much as in the G01 example.

To fully cross-check things here, can you confirm that in XERCESCROOT\src\xercesc the subdirectories:

  1. bin contains a .dll file(s) for Xerces-C
  2. include contains a xercesc subdirectory, and subsequently xercesc/parsers/XercesDOMParser.hpp
  3. lib contains .lib file(s) for Xerces-C (may also be in bin)

I’m only asking this because the error:

feels like there isn’t a proper install of xerces-c under XERCESCROOT\src\xercesc. Whether building Geant4 or G01, those variables should almost never need setting for CMake to find things correctly. How did you install Xerces-C?

As for the installation. Just the usual. Downloaded the zipfile → unzipped → cmake to the build folder → cmake --build . --config Release → cmake --build . --config Release --target install

HUH! Ok. Weird. I put the -DCMAKE_PREFIX_PATH in quotes like Weller did and this didn’t give me any problems now this time. I don’t know why this happened because there was no spaces or special characters in the path.

Ok. Let me try this again …

Nope. Still same problem.

.\geant4_10_07_p02\source\persistency\gdml\include\G4GDMLRead.hh(37,10): fatal error C1
083: Cannot open include file: ‘/xercesc/parsers/XercesDOMParser.hpp’: No such file or directory [.\G01_Build\load_gdml.vcxproj]

That would suggest that CMake is thinking it’s found Xerces o.k., but it hasn’t actually got the right include path. A few things to check:

  • In the Geant4 folder where you built Geant4, there should be files CMakeCache.txt , Geant4Config.cmake and Geant4PackageCache.cmake. Check each of these for any XercesC_... variables, especially those listed here: FindXercesC — CMake 3.22.0 Documentation, and post them here (as text, screenshots aren’t helpful for this kind of info)
  • In the G01Build folder where you’re building the example, there’ll be another CMakeCache.txt file. Check that for any XercesC_... variables and post them here.

Hi. So in CMakeCache.txt, we have
//Xerces-C++ include directory
XercesC_INCLUDE_DIR:PATH=C:/Users/siygu/Documents/XERCESCROOT/src/xercesc/include

//Xerces-C++ libraries (debug)
XercesC_LIBRARY_DEBUG:FILEPATH=XercesC_LIBRARY_DEBUG-NOTFOUND

//Xerces-C++ libraries (release)
XercesC_LIBRARY_RELEASE:FILEPATH=C:/Users/siygu/Documents/XERCESCROOT/src/xercesc/lib/xerces-c_3.lib

FIND_PACKAGE_MESSAGE_DETAILS_Threads:INTERNAL=[TRUE][v()]
//Details about finding XercesC
FIND_PACKAGE_MESSAGE_DETAILS_XercesC:INTERNAL=[C:/Users/siygu/Documents/XERCESCROOT/src/xercesc/lib/xerces-c_3.lib][C:/Users/siygu/Documents/XERCESCROOT/src/xercesc/include][3.2.3][v3.2.3()]

//Have include stdlib.h;stdarg.h;string.h;float.h
STDC_HEADERS:INTERNAL=1
//ADVANCED property for variable: XercesC_INCLUDE_DIR
XercesC_INCLUDE_DIR-ADVANCED:INTERNAL=1
//ADVANCED property for variable: XercesC_LIBRARY_DEBUG
XercesC_LIBRARY_DEBUG-ADVANCED:INTERNAL=1
//ADVANCED property for variable: XercesC_LIBRARY_RELEASE
XercesC_LIBRARY_RELEASE-ADVANCED:INTERNAL=1


In Geant4Config.cmake, we have
if(Geant4_gdml_FOUND)
find_dependency(XercesC 3.2.3)
endif()


And in Geant4PackageCache.cmake, we have
# XercesC Build Time Settings
geant4_set_and_check_package_variable(XercesC_INCLUDE_DIR “C:/Users/siygu/Documents/XERCESCROOT/src/xercesc/include” PATH “Xerces-C++ include directory”)
geant4_set_and_check_package_variable(XercesC_LIBRARY_RELEASE “C:/Users/siygu/Documents/XERCESCROOT/src/xercesc/lib/xerces-c_3.lib” FILEPATH “Xerces-C++ libraries (release)”)

Thanks for the info! These paths look o.k., so given the error message from earlier, is there a file
C:/Users/siygu/Documents/XERCESCROOT/src/xercesc/include/xercesc/parsers/XercesDOMParser.hpp present?

Given that the above files are for the build of Geant4 in the Geant4 folder, I think that build is probably o.k. Going back to G01, I think it’s best to delete both the G01 and G01Build folders and start from scratch in trying to build. What I’d suggest to ensure these are really isolated is to:

  1. Start in C:/Users/siygu/Documents and create a folder G01Example.

  2. Copy G01 from C:/Users/siygu/Documents/geant4_10_07_p02/examples/extended/persistency/gdml/G01 into G01Example and also create a folder G01Build. i.e. there are now two folders:

    • C:/Users/siygu/Documents/G01Example/G01
    • C:/Users/siygu/Documents/G01Example/G01Build.
  3. In C:/Users/siygu/Documents/G01Example/G01Build, run cmake as:

    cmake -DGeant4_DIR="C:/Users/siygu/Documents/Geant4" ../G01
    

    This should work - as the location of Xerces-C is known to Geant4 in the Geant4PackageCache file. If there are errors at this point, please post them here.

  4. If the above was successful, try running

    cmake --build . --config Release --verbose
    

    The --verbose option will give more output. Again, if this fails, post the output here.

Thanks Ben.

Here is the output:
LINK : fatal error LNK1181: cannot open input file ‘C:\Users\siygu\Documents\Geant4\BuildProducts
Release\lib\G4Tree.lib’ [C:\Users\siygu\Documents\G01Example\G01Build\load_gdml.vcxproj]
Done Building Project “C:\Users\siygu\Documents\G01Example\G01Build\load_gdml.vcxproj” (default ta
rgets) – FAILED.

Done Building Project “C:\Users\siygu\Documents\G01Example\G01Build\ALL_BUILD.vcxproj” (default ta
rgets) – FAILED.

Build FAILED.

“C:\Users\siygu\Documents\G01Example\G01Build\ALL_BUILD.vcxproj” (default target) (1) →
“C:\Users\siygu\Documents\G01Example\G01Build\load_gdml.vcxproj” (default target) (3) →
(Link target) →
LINK : fatal error LNK1181: cannot open input file ‘C:\Users\siygu\Documents\Geant4\BuildProduct
s\Release\lib\G4Tree.lib’ [C:\Users\siygu\Documents\G01Example\G01Build\load_gdml.vcxproj]

Is this file present and with readable permissions?

Ah. I had to unzip a new copy of geant4_10_07_p02. Everything compiles now.