Geant4 and HepMC

Hello, I’m trying to run a Geant4 simulation based on HepMC on windows Machine.

  1. I installed vcpkg pthreads and it looks like it was succesfully

pthread.txt (4.6 KB)

  1. I installed HepMC and it looks like it was succesfully

HepMC.txt (114.4 KB)

but when I build the simulation I get error

**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.9.2
** Copyright (c) 2021 Microsoft Corporation
**********************************************************************

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community>cd C:\setup\build

C:\setup\build>cmake -DGeant4_DIR="C:\Program Files\geant4_10_07_p01_install\lib\Geant4-10.7.1" "C:\setup"
-- Building for: Visual Studio 16 2019
CMake Deprecation Warning at CMakeLists.txt:5 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19042.
-- The C compiler identification is MSVC 19.28.29913.0
-- The CXX compiler identification is MSVC 19.28.29913.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - not found
-- Found Threads: TRUE
-- Found XercesC: C:/Program Files/xerces-c-3.2.3-install/lib/xerces-c_3.lib (found suitable version "3.2.3", minimum required is "3.2.3")
-- Found OpenGL: opengl32
CMake Error at C:/Program Files/CMake/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find HepMC (missing: HEPMC_INCLUDE_DIR HEPMC_LIBRARIES)
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
  C:/Program Files/geant4_10_07_p01_install/lib/Geant4-10.7.1/Modules/FindHepMC.cmake:27 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:30 (find_package)


-- Configuring incomplete, errors occurred!
See also "C:/setup/build/CMakeFiles/CMakeOutput.log".
See also "C:/setup/build/CMakeFiles/CMakeError.log".

C:\setup\build>

Here the log
CMakeError.txt (1.2 KB)

it says that it can’t find pthread.h but I installed it by vcpkg it is in the directory C:\vcpkg\vcpkg\buildtrees\pthreads\src\49e541b66c-53502e357c.clean then I setted the enviroment variable path…moreover I also copied it in the building directory of the simulation…

@bmorgan maybe do you know the problem?
Thank you

The cause of the error is right there in the output, and nothing to do with pthread:

CMake Error at C:/Program Files/CMake/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find HepMC (missing: HEPMC_INCLUDE_DIR HEPMC_LIBRARIES)
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
  C:/Program Files/geant4_10_07_p01_install/lib/Geant4-10.7.1/Modules/FindHepMC.cmake:27 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:30 (find_package)

It couldn’t find the HepMC you installed at C:/Program Files/HepMC3-install, so try running Cmake again with:

cmake -DGeant4_DIR="C:\Program Files\geant4_10_07_p01_install\lib\Geant4-10.7.1"  -DCMAKE_PREFIX_PATH="C:/Program Files/HepMC3-install" "C:\setup"

How CMake finds packages is fully documented here and here

Hello @bmorgan unfortunately, I still get error

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community>cd C:/setup/build

C:\setup\build>cmake -DGeant4_DIR="C:\Program Files\geant4_10_07_p01_install\lib\Geant4-10.7.1"  -DCMAKE_PREFIX_PATH="C:/Program Files/HepMC3-install" "C:\setup"
-- Building for: Visual Studio 16 2019
CMake Deprecation Warning at CMakeLists.txt:5 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19042.
-- The C compiler identification is MSVC 19.28.29913.0
-- The CXX compiler identification is MSVC 19.28.29913.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - not found
-- Found Threads: TRUE
-- Found XercesC: C:/Program Files/xerces-c-3.2.3-install/lib/xerces-c_3.lib (found suitable version "3.2.3", minimum required is "3.2.3")
-- Found OpenGL: opengl32
CMake Error at C:/Program Files/CMake/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find HepMC (missing: HEPMC_INCLUDE_DIR HEPMC_LIBRARIES)
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
  C:/Program Files/geant4_10_07_p01_install/lib/Geant4-10.7.1/Modules/FindHepMC.cmake:27 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:30 (find_package)


-- Configuring incomplete, errors occurred!
See also "C:/setup/build/CMakeFiles/CMakeOutput.log".
See also "C:/setup/build/CMakeFiles/CMakeError.log".

C:\setup\build>

CMakeError.txt (1.2 KB)

Could you post the CMakeLists.txt you’re using please? I think there’s a mix up between HepMC and HepMC3 going on, so use of find_package etc.

Hello @bmorgan do you mean the CMakeList of the simulation?
If yes here
CMakeLists.txt (3.5 KB)

Thanks for the info! What’s happening is that the application’s CMakeLists.txt is searching for HepMC, not the HepMC3 that you installed - so there are two things to try:

  • Try installing HepMC: HepMC / HepMC. I’m not sure of its status on Windows though. After installing it, say to C:/Program Files/HepMC-install, you can point CMAKE_PREFIX_PATH to it in the same way as suggested above
  • Try changing the find_package(HepMC REQUIRED) in the CMakeLists.txt to find_package(HepMC3 REQUIRED). With the cmake command from before that should find HepMC3 where you installed it. However… it’s likely that if the application really uses HepMC it may not compile and error out with messages about missing headers etc.

I’d try the first option, then the second if HepMC has issues building on Windows. HepMC3 is more actively developed by the looks of things, so may be better to migrate the application to that in the long term.

Hello @bmorgan

…unfortunately, HepMC building gives error

C:\Windows\System32>cd C:\Program Files

C:\Program Files>git clone https://gitlab.cern.ch/hepmc/HepMC.git
Cloning into 'HepMC'...
remote: Enumerating objects: 4445, done.
remote: Counting objects: 100% (4445/4445), done.
remote: Compressing objects: 100% (967/967), done.
remote: Total 4445 (delta 3568), reused 4333 (delta 3466), pack-reused 0 eceiving objects: 100% (4445/4445), 11.30 MiB |Receiving objects: 100% (4445/4445), 11.43 MiB | 652.00 KiB/s, done.

Resolving deltas: 100% (3568/3568), done.

C:\Program Files>cd C:\Program Files\HepMC-build

C:\Program Files\HepMC-build>cmake -DHEPMC_ENABLE_ROOTIO=OFF -DCMAKE_INSTALL_PREFIX=../HepMC-install ../HepMC
-- Building for: Visual Studio 16 2019
CMake Deprecation Warning at CMakeLists.txt:17 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19042.
-- The C compiler identification is MSVC 19.28.29913.0
-- The CXX compiler identification is MSVC 19.28.29913.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:26 (message):
  You must specify the momentum units with -Dmomentum=[MEV|GEV]


-- Configuring incomplete, errors occurred!
See also "C:/Program Files/HepMC-build/CMakeFiles/CMakeOutput.log".

C:\Program Files\HepMC-build>

here the log CMakeOutput.txt (7.5 KB)

Then I tried to replace
find_package(HepMC REQUIRED)
by
find_package(HepMC3 REQUIRED)

the building was succesfully but when I runned the command

cmake --build . --config Release

I got this error

C:\setup\include\HepMCG4Interface.hh(36,10): fatal error C1083: Non è possibile aprire il file inclusione: ‘HepMC/GenEvent.h’: No such fil
e or directory (compilazione del file di origine C:\setup\src\B1PrimaryGeneratorAction.cc) [C:\setup\build\mainMCMC.vcxproj]

here the log
log1.txt (13.1 KB)

Then I tried replacing HepMC/GenEvent.h by HepMC3/GenEvent.h

in the include\HepMCG4Interface.hh

but I get the error

C:\setup\include\HepMCG4Interface.hh(36,10): fatal error C1083: Non è possibile aprire il file inclusione: 'HepMC3/GenE
vent.h': No such file or directory (compilazione del file di origine C:\setup\src\HepMCG4Interface.cc) [C:\setup\build\
mainMCMC.vcxproj]

here the log

log2.txt (13.0 KB)

then I replaced

HepMC3/GenEvent.h by C:\Program Files\HepMC3-install\include\HepMC3\GenEvent.h

then it didn’t find HepMC3/Units.h

C:\Program Files\HepMC3-install\include\HepMC3\GenEvent.h(13,10): fatal error C1083: Non è possibile aprire il file inc
lusione: 'HepMC3/Units.h': No such file or directory (compilazione del file di origine C:\setup\src\HepMCG4Interface.cc
) [C:\setup\build\mainMCMC.vcxproj]

So I copied all the header files in HepMC3 subdirectory
C:\Program Files\HepMC3-install\include\HepMC3\HepMC3

but everyttime it can’t find new things

**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.9.2
** Copyright (c) 2021 Microsoft Corporation
**********************************************************************

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community>cd C:/setup/build

C:\setup\build>cmake -DGeant4_DIR="C:\Program Files\geant4_10_07_p01_install\lib\Geant4-10.7.1"  -DCMAKE_PREFIX_PATH="C:/Program Files/HepMC3-install" "C:\setup"
-- Building for: Visual Studio 16 2019
CMake Deprecation Warning at CMakeLists.txt:5 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19042.
-- The C compiler identification is MSVC 19.28.29913.0
-- The CXX compiler identification is MSVC 19.28.29913.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - not found
-- Found Threads: TRUE
-- Found XercesC: C:/Program Files/xerces-c-3.2.3-install/lib/xerces-c_3.lib (found suitable version "3.2.3", minimum required is "3.2.3")
-- Found OpenGL: opengl32
-- Configuring done
-- Generating done
-- Build files have been written to: C:/setup/build

C:\setup\build>cmake --build . --config Release
Microsoft (R) Build Engine versione 16.9.0+57a23d249 per .NET Framework
Copyright (C) Microsoft Corporation. Tutti i diritti sono riservati.

  Checking Build System
  Building Custom Rule C:/setup/CMakeLists.txt
  mainMCMC.cc
  G4Channeling.cc
  G4ChannelingECHARM.cc
  G4ChannelingMaterialData.cc
  G4ChannelingOptrChangeCrossSection.cc
  G4ChannelingOptrMultiParticleChangeCrossSection.cc
  G4ChannelingPhysics.cc
  G4ChannelingTrackData.cc
  B1ActionInitialization.cc
  B1DetectorConstruction.cc
  B1DetectorConstructionAug.cc
  B1EventAction.cc
  B1PrimaryGeneratorAction.cc
C:\setup\mainMCMC.cc(225,14): warning C4244: 'inizializzazione': conversione da 'time_t' a 'G4long'. Possibile perdita
di dati. [C:\setup\build\mainMCMC.vcxproj]
  B1Run.cc
  B1RunAction.cc
  B1RunAction2018.cc
  B1StackingAction.cc
C:\Program Files\HepMC3-install\include\HepMC3\HepMC3/Errors.h(16,10): fatal error C1083: Non è possibile aprire il fil
e inclusione: 'HepMC3/Setup.h': No such file or directory (compilazione del file di origine C:\setup\src\B1PrimaryGener
atorAction.cc) [C:\setup\build\mainMCMC.vcxproj]
  B1SteppingAction.cc
  B1SteppingAction2018.cc
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(106,21): warning C4996: 'write': The POSIX na
me for this item is deprecated. Instead, use the ISO C and C++ conformant name: _write. See online help for details. (c
ompilazione del file di origine C:\setup\src\B1RunAction.cc) [C:\setup\build\mainMCMC.vcxproj]
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(393,7): warning C4996: 'close': The POSIX nam
e for this item is deprecated. Instead, use the ISO C and C++ conformant name: _close. See online help for details. (co
mpilazione del file di origine C:\setup\src\B1RunAction.cc) [C:\setup\build\mainMCMC.vcxproj]
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(482,17): warning C4996: 'unlink': The POSIX n
ame for this item is deprecated. Instead, use the ISO C and C++ conformant name: _unlink. See online help for details.
(compilazione del file di origine C:\setup\src\B1RunAction.cc) [C:\setup\build\mainMCMC.vcxproj]
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(495,15): warning C4996: 'open': The POSIX nam
e for this item is deprecated. Instead, use the ISO C and C++ conformant name: _open. See online help for details. (com
pilazione del file di origine C:\setup\src\B1RunAction.cc) [C:\setup\build\mainMCMC.vcxproj]
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(106,21): warning C4996: 'write': The POSIX na
me for this item is deprecated. Instead, use the ISO C and C++ conformant name: _write. See online help for details. (c
ompilazione del file di origine C:\setup\src\B1EventAction.cc) [C:\setup\build\mainMCMC.vcxproj]
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(393,7): warning C4996: 'close': The POSIX nam
e for this item is deprecated. Instead, use the ISO C and C++ conformant name: _close. See online help for details. (co
mpilazione del file di origine C:\setup\src\B1EventAction.cc) [C:\setup\build\mainMCMC.vcxproj]
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(482,17): warning C4996: 'unlink': The POSIX n
ame for this item is deprecated. Instead, use the ISO C and C++ conformant name: _unlink. See online help for details.
(compilazione del file di origine C:\setup\src\B1EventAction.cc) [C:\setup\build\mainMCMC.vcxproj]
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(495,15): warning C4996: 'open': The POSIX nam
e for this item is deprecated. Instead, use the ISO C and C++ conformant name: _open. See online help for details. (com
pilazione del file di origine C:\setup\src\B1EventAction.cc) [C:\setup\build\mainMCMC.vcxproj]
C:\setup\src\B1EventAction.cc(358,34): warning C4267: '=': conversione da 'size_t' a 'G4int'. Possibile perdita di dati
. [C:\setup\build\mainMCMC.vcxproj]
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(106,21): warning C4996: 'write': The POSIX na
me for this item is deprecated. Instead, use the ISO C and C++ conformant name: _write. See online help for details. (c
ompilazione del file di origine C:\setup\src\B1RunAction2018.cc) [C:\setup\build\mainMCMC.vcxproj]
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(393,7): warning C4996: 'close': The POSIX nam
e for this item is deprecated. Instead, use the ISO C and C++ conformant name: _close. See online help for details. (co
mpilazione del file di origine C:\setup\src\B1RunAction2018.cc) [C:\setup\build\mainMCMC.vcxproj]
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(482,17): warning C4996: 'unlink': The POSIX n
ame for this item is deprecated. Instead, use the ISO C and C++ conformant name: _unlink. See online help for details.
(compilazione del file di origine C:\setup\src\B1RunAction2018.cc) [C:\setup\build\mainMCMC.vcxproj]
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(495,15): warning C4996: 'open': The POSIX nam
e for this item is deprecated. Instead, use the ISO C and C++ conformant name: _open. See online help for details. (com
pilazione del file di origine C:\setup\src\B1RunAction2018.cc) [C:\setup\build\mainMCMC.vcxproj]
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(106,21): warning C4996: 'write': The POSIX na
me for this item is deprecated. Instead, use the ISO C and C++ conformant name: _write. See online help for details. (c
ompilazione del file di origine C:\setup\src\B1StackingAction.cc) [C:\setup\build\mainMCMC.vcxproj]
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(393,7): warning C4996: 'close': The POSIX nam
e for this item is deprecated. Instead, use the ISO C and C++ conformant name: _close. See online help for details. (co
mpilazione del file di origine C:\setup\src\B1StackingAction.cc) [C:\setup\build\mainMCMC.vcxproj]
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(482,17): warning C4996: 'unlink': The POSIX n
ame for this item is deprecated. Instead, use the ISO C and C++ conformant name: _unlink. See online help for details.
(compilazione del file di origine C:\setup\src\B1StackingAction.cc) [C:\setup\build\mainMCMC.vcxproj]
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(495,15): warning C4996: 'open': The POSIX nam
e for this item is deprecated. Instead, use the ISO C and C++ conformant name: _open. See online help for details. (com
pilazione del file di origine C:\setup\src\B1StackingAction.cc) [C:\setup\build\mainMCMC.vcxproj]
C:\setup\src\B1RunAction.cc(394,86): warning C4244: 'argomento': conversione da 'unsigned __int64' a 'G4double'. Possib
ile perdita di dati. [C:\setup\build\mainMCMC.vcxproj]
C:\setup\src\B1RunAction.cc(394,88): warning C4267: 'argomento': conversione da 'size_t' a 'G4int'. Possibile perdita d
i dati. [C:\setup\build\mainMCMC.vcxproj]
C:\setup\src\B1RunAction2018.cc(393,86): warning C4244: 'argomento': conversione da 'unsigned __int64' a 'G4double'. Po
ssibile perdita di dati. [C:\setup\build\mainMCMC.vcxproj]
C:\setup\src\B1RunAction2018.cc(393,88): warning C4267: 'argomento': conversione da 'size_t' a 'G4int'. Possibile perdi
ta di dati. [C:\setup\build\mainMCMC.vcxproj]
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(106,21): warning C4996: 'write': The POSIX na
me for this item is deprecated. Instead, use the ISO C and C++ conformant name: _write. See online help for details. (c
ompilazione del file di origine C:\setup\src\B1SteppingAction.cc) [C:\setup\build\mainMCMC.vcxproj]
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(393,7): warning C4996: 'close': The POSIX nam
e for this item is deprecated. Instead, use the ISO C and C++ conformant name: _close. See online help for details. (co
mpilazione del file di origine C:\setup\src\B1SteppingAction.cc) [C:\setup\build\mainMCMC.vcxproj]
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(482,17): warning C4996: 'unlink': The POSIX n
ame for this item is deprecated. Instead, use the ISO C and C++ conformant name: _unlink. See online help for details.
(compilazione del file di origine C:\setup\src\B1SteppingAction.cc) [C:\setup\build\mainMCMC.vcxproj]
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(495,15): warning C4996: 'open': The POSIX nam
e for this item is deprecated. Instead, use the ISO C and C++ conformant name: _open. See online help for details. (com
pilazione del file di origine C:\setup\src\B1SteppingAction.cc) [C:\setup\build\mainMCMC.vcxproj]
C:\setup\src\B1SteppingAction.cc(693,55): warning C4267: 'inizializzazione': conversione da 'size_t' a 'int'. Possibile
 perdita di dati. [C:\setup\build\mainMCMC.vcxproj]
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(106,21): warning C4996: 'write': The POSIX na
me for this item is deprecated. Instead, use the ISO C and C++ conformant name: _write. See online help for details. (c
ompilazione del file di origine C:\setup\src\B1SteppingAction2018.cc) [C:\setup\build\mainMCMC.vcxproj]
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(393,7): warning C4996: 'close': The POSIX nam
e for this item is deprecated. Instead, use the ISO C and C++ conformant name: _close. See online help for details. (co
mpilazione del file di origine C:\setup\src\B1SteppingAction2018.cc) [C:\setup\build\mainMCMC.vcxproj]
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(482,17): warning C4996: 'unlink': The POSIX n
ame for this item is deprecated. Instead, use the ISO C and C++ conformant name: _unlink. See online help for details.
(compilazione del file di origine C:\setup\src\B1SteppingAction2018.cc) [C:\setup\build\mainMCMC.vcxproj]
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(495,15): warning C4996: 'open': The POSIX nam
e for this item is deprecated. Instead, use the ISO C and C++ conformant name: _open. See online help for details. (com
pilazione del file di origine C:\setup\src\B1SteppingAction2018.cc) [C:\setup\build\mainMCMC.vcxproj]
  GEMDigitizer.cc
  HepMCG4AsciiReader.cc
  HepMCG4Interface.cc
  PhysicsList.cc
C:\Program Files\HepMC3-install\include\HepMC3\HepMC3/Errors.h(16,10): fatal error C1083: Non è possibile aprire il fil
e inclusione: 'HepMC3/Setup.h': No such file or directory (compilazione del file di origine C:\setup\src\HepMCG4Interfa
ce.cc) [C:\setup\build\mainMCMC.vcxproj]
  PhysicsListMessenger.cc
  PurgMagTabulatedField3D.cc
C:\setup\src\GEMDigitizer.cc(29,14): warning C4244: 'inizializzazione': conversione da 'double' a 'int'. Possibile perd
ita di dati. [C:\setup\build\mainMCMC.vcxproj]
C:\Program Files\HepMC3-install\include\HepMC3\HepMC3/Errors.h(16,10): fatal error C1083: Non è possibile aprire il fil
e inclusione: 'HepMC3/Setup.h': No such file or directory (compilazione del file di origine C:\setup\src\HepMCG4AsciiRe
ader.cc) [C:\setup\build\mainMCMC.vcxproj]
  SiDigitizer.cc
  TBDetectorConstruction.cc

C:\setup\build>

Right, the issue is that the executable is still trying to use/link to the HepMC headers via the HEPMC_... variables in the CMakeLists.txt. Try changing those to to HEPMC3_....

Hello @bmorgan

1)I copied again the application (to have the original source files and not the modified one)

2)[I modified the CMakeList iin order to call HEPMC3

CMakeLists.txt|attachment](upload://f8e79gzq5e2OonktILrQrk5IJ9l.txt) (3.5 KB)

but I still get the error that it can’t find HEPMC

**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.9.2
** Copyright (c) 2021 Microsoft Corporation
**********************************************************************

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community>cd C:\setup\build

C:\setup\build>cmake -DGeant4_DIR="C:\Program Files\geant4_10_07_p01_install\lib\Geant4-10.7.1"  -DCMAKE_PREFIX_PATH="C:/Program Files/HepMC3-install" "C:\setup"
-- Building for: Visual Studio 16 2019
CMake Deprecation Warning at CMakeLists.txt:5 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19042.
-- The C compiler identification is MSVC 19.28.29913.0
-- The CXX compiler identification is MSVC 19.28.29913.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - not found
-- Found Threads: TRUE
-- Found XercesC: C:/Program Files/xerces-c-3.2.3-install/lib/xerces-c_3.lib (found suitable version "3.2.3", minimum required is "3.2.3")
-- Found OpenGL: opengl32
-- Configuring done
-- Generating done
-- Build files have been written to: C:/setup/build

C:\setup\build>cmake --build . --config Release
Microsoft (R) Build Engine versione 16.9.0+57a23d249 per .NET Framework
Copyright (C) Microsoft Corporation. Tutti i diritti sono riservati.

  Checking Build System
  Building Custom Rule C:/setup/CMakeLists.txt
  mainMCMC.cc
  G4Channeling.cc
  G4ChannelingECHARM.cc
  G4ChannelingMaterialData.cc
  G4ChannelingOptrChangeCrossSection.cc
  G4ChannelingOptrMultiParticleChangeCrossSection.cc
  G4ChannelingPhysics.cc
  G4ChannelingTrackData.cc
  B1ActionInitialization.cc
  B1DetectorConstruction.cc
  B1DetectorConstructionAug.cc
  B1EventAction.cc
  B1PrimaryGeneratorAction.cc
  B1Run.cc
  B1RunAction.cc
  B1RunAction2018.cc
  B1StackingAction.cc
C:\setup\include\HepMCG4Interface.hh(36,10): fatal error C1083: Non è possibile aprire il file inclusione: 'HepMC/GenEv
ent.h': No such file or directory (compilazione del file di origine C:\setup\src\B1PrimaryGeneratorAction.cc) [C:\setup
\build\mainMCMC.vcxproj]
  B1SteppingAction.cc
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(106,21): warning C4996: 'write': The POSIX na
me for this item is deprecated. Instead, use the ISO C and C++ conformant name: _write. See online help for details. (c
ompilazione del file di origine C:\setup\src\B1StackingAction.cc) [C:\setup\build\mainMCMC.vcxproj]
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(106,21): warning C4996: 'write': The POSIX na
me for this item is deprecated. Instead, use the ISO C and C++ conformant name: _write. See online help for details. (c
ompilazione del file di origine C:\setup\src\B1RunAction.cc) [C:\setup\build\mainMCMC.vcxproj]
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(106,21): warning C4996: 'write': The POSIX na
me for this item is deprecated. Instead, use the ISO C and C++ conformant name: _write. See online help for details. (c
ompilazione del file di origine C:\setup\src\B1RunAction2018.cc) [C:\setup\build\mainMCMC.vcxproj]
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(106,21): warning C4996: 'write': The POSIX na
me for this item is deprecated. Instead, use the ISO C and C++ conformant name: _write. See online help for details. (c
ompilazione del file di origine C:\setup\src\B1EventAction.cc) [C:\setup\build\mainMCMC.vcxproj]
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(393,7): warning C4996: 'close': The POSIX nam
e for this item is deprecated. Instead, use the ISO C and C++ conformant name: _close. See online help for details. (co
mpilazione del file di origine C:\setup\src\B1StackingAction.cc) [C:\setup\build\mainMCMC.vcxproj]
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(393,7): warning C4996: 'close': The POSIX nam
e for this item is deprecated. Instead, use the ISO C and C++ conformant name: _close. See online help for details. (co
mpilazione del file di origine C:\setup\src\B1RunAction.cc) [C:\setup\build\mainMCMC.vcxproj]
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(393,7): warning C4996: 'close': The POSIX nam
e for this item is deprecated. Instead, use the ISO C and C++ conformant name: _close. See online help for details. (co
mpilazione del file di origine C:\setup\src\B1RunAction2018.cc) [C:\setup\build\mainMCMC.vcxproj]
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(482,17): warning C4996: 'unlink': The POSIX n
ame for this item is deprecated. Instead, use the ISO C and C++ conformant name: _unlink. See online help for details.
(compilazione del file di origine C:\setup\src\B1RunAction2018.cc) [C:\setup\build\mainMCMC.vcxproj]
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(482,17): warning C4996: 'unlink': The POSIX n
ame for this item is deprecated. Instead, use the ISO C and C++ conformant name: _unlink. See online help for details.
(compilazione del file di origine C:\setup\src\B1RunAction.cc) [C:\setup\build\mainMCMC.vcxproj]
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(495,15): warning C4996: 'open': The POSIX nam
e for this item is deprecated. Instead, use the ISO C and C++ conformant name: _open. See online help for details. (com
pilazione del file di origine C:\setup\src\B1RunAction.cc) [C:\setup\build\mainMCMC.vcxproj]
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(495,15): warning C4996: 'open': The POSIX nam
e for this item is deprecated. Instead, use the ISO C and C++ conformant name: _open. See online help for details. (com
pilazione del file di origine C:\setup\src\B1RunAction2018.cc) [C:\setup\build\mainMCMC.vcxproj]
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(482,17): warning C4996: 'unlink': The POSIX n
ame for this item is deprecated. Instead, use the ISO C and C++ conformant name: _unlink. See online help for details.
(compilazione del file di origine C:\setup\src\B1StackingAction.cc) [C:\setup\build\mainMCMC.vcxproj]
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(495,15): warning C4996: 'open': The POSIX nam
e for this item is deprecated. Instead, use the ISO C and C++ conformant name: _open. See online help for details. (com
pilazione del file di origine C:\setup\src\B1StackingAction.cc) [C:\setup\build\mainMCMC.vcxproj]
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(393,7): warning C4996: 'close': The POSIX nam
e for this item is deprecated. Instead, use the ISO C and C++ conformant name: _close. See online help for details. (co
mpilazione del file di origine C:\setup\src\B1EventAction.cc) [C:\setup\build\mainMCMC.vcxproj]
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(482,17): warning C4996: 'unlink': The POSIX n
ame for this item is deprecated. Instead, use the ISO C and C++ conformant name: _unlink. See online help for details.
(compilazione del file di origine C:\setup\src\B1EventAction.cc) [C:\setup\build\mainMCMC.vcxproj]
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(495,15): warning C4996: 'open': The POSIX nam
e for this item is deprecated. Instead, use the ISO C and C++ conformant name: _open. See online help for details. (com
pilazione del file di origine C:\setup\src\B1EventAction.cc) [C:\setup\build\mainMCMC.vcxproj]
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(106,21): warning C4996: 'write': The POSIX na
me for this item is deprecated. Instead, use the ISO C and C++ conformant name: _write. See online help for details. (c
ompilazione del file di origine C:\setup\src\B1SteppingAction.cc) [C:\setup\build\mainMCMC.vcxproj]
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(393,7): warning C4996: 'close': The POSIX nam
e for this item is deprecated. Instead, use the ISO C and C++ conformant name: _close. See online help for details. (co
mpilazione del file di origine C:\setup\src\B1SteppingAction.cc) [C:\setup\build\mainMCMC.vcxproj]
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(482,17): warning C4996: 'unlink': The POSIX n
ame for this item is deprecated. Instead, use the ISO C and C++ conformant name: _unlink. See online help for details.
(compilazione del file di origine C:\setup\src\B1SteppingAction.cc) [C:\setup\build\mainMCMC.vcxproj]
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(495,15): warning C4996: 'open': The POSIX nam
e for this item is deprecated. Instead, use the ISO C and C++ conformant name: _open. See online help for details. (com
pilazione del file di origine C:\setup\src\B1SteppingAction.cc) [C:\setup\build\mainMCMC.vcxproj]
C:\setup\src\B1EventAction.cc(358,34): warning C4267: '=': conversione da 'size_t' a 'G4int'. Possibile perdita di dati
. [C:\setup\build\mainMCMC.vcxproj]
C:\setup\mainMCMC.cc(225,14): warning C4244: 'inizializzazione': conversione da 'time_t' a 'G4long'. Possibile perdita
di dati. [C:\setup\build\mainMCMC.vcxproj]
C:\setup\src\B1SteppingAction.cc(693,55): warning C4267: 'inizializzazione': conversione da 'size_t' a 'int'. Possibile
 perdita di dati. [C:\setup\build\mainMCMC.vcxproj]
C:\setup\src\B1RunAction2018.cc(393,86): warning C4244: 'argomento': conversione da 'unsigned __int64' a 'G4double'. Po
ssibile perdita di dati. [C:\setup\build\mainMCMC.vcxproj]
C:\setup\src\B1RunAction.cc(394,86): warning C4244: 'argomento': conversione da 'unsigned __int64' a 'G4double'. Possib
ile perdita di dati. [C:\setup\build\mainMCMC.vcxproj]
C:\setup\src\B1RunAction2018.cc(393,88): warning C4267: 'argomento': conversione da 'size_t' a 'G4int'. Possibile perdi
ta di dati. [C:\setup\build\mainMCMC.vcxproj]
C:\setup\src\B1RunAction.cc(394,88): warning C4267: 'argomento': conversione da 'size_t' a 'G4int'. Possibile perdita d
i dati. [C:\setup\build\mainMCMC.vcxproj]
  B1SteppingAction2018.cc
  GEMDigitizer.cc
  HepMCG4AsciiReader.cc
  HepMCG4Interface.cc
  PhysicsList.cc
C:\setup\src\GEMDigitizer.cc(29,14): warning C4244: 'inizializzazione': conversione da 'double' a 'int'. Possibile perd
ita di dati. [C:\setup\build\mainMCMC.vcxproj]
  PhysicsListMessenger.cc
C:\setup\include\HepMCG4Interface.hh(36,10): fatal error C1083: Non è possibile aprire il file inclusione: 'HepMC/GenEv
ent.h': No such file or directory (compilazione del file di origine C:\setup\src\HepMCG4Interface.cc) [C:\setup\build\m
ainMCMC.vcxproj]
C:\setup\include\HepMCG4Interface.hh(36,10): fatal error C1083: Non è possibile aprire il file inclusione: 'HepMC/GenEv
ent.h': No such file or directory (compilazione del file di origine C:\setup\src\HepMCG4AsciiReader.cc) [C:\setup\build
\mainMCMC.vcxproj]
  PurgMagTabulatedField3D.cc
  SiDigitizer.cc
  TBDetectorConstruction.cc
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(106,21): warning C4996: 'write': The POSIX na
me for this item is deprecated. Instead, use the ISO C and C++ conformant name: _write. See online help for details. (c
ompilazione del file di origine C:\setup\src\B1SteppingAction2018.cc) [C:\setup\build\mainMCMC.vcxproj]
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(393,7): warning C4996: 'close': The POSIX nam
e for this item is deprecated. Instead, use the ISO C and C++ conformant name: _close. See online help for details. (co
mpilazione del file di origine C:\setup\src\B1SteppingAction2018.cc) [C:\setup\build\mainMCMC.vcxproj]
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(482,17): warning C4996: 'unlink': The POSIX n
ame for this item is deprecated. Instead, use the ISO C and C++ conformant name: _unlink. See online help for details.
(compilazione del file di origine C:\setup\src\B1SteppingAction2018.cc) [C:\setup\build\mainMCMC.vcxproj]
C:\Program Files\geant4_10_07_p01_install\include\Geant4\tools\wroot\file(495,15): warning C4996: 'open': The POSIX nam
e for this item is deprecated. Instead, use the ISO C and C++ conformant name: _open. See online help for details. (com
pilazione del file di origine C:\setup\src\B1SteppingAction2018.cc) [C:\setup\build\mainMCMC.vcxproj]

C:\setup\build>

Moreover, I also tried to install HepMC (notice, I mean HepMC and not HepMC3) on my area in the machine of the laboratory (CMakeOutput.txt (47.6 KB) linux machine). Unfortunately, you can see …I got error to install it on this machine too

This is the same error as before - it’s looking for a HepMC header, but HepMC3 has been installed/looked for.

For the linux error with HepMC, see the HepMC project page and the install instructions

Hello @bgmorgan the reasercher who gave me the simulation could install HepMC on laboratory machine. Now I can build the simulation, but when I run I get this error

*************************************************************
 Geant4 version Name: geant4-10-06-patch-02 [MT]   (29-May-2020)
                       Copyright : Geant4 Collaboration
                      References : NIM A 506 (2003), 250-303
                                 : IEEE-TNS 53 (2006), 270-278
                                 : NIM A 835 (2016), 186-225
                             WWW : http://geant4.org/
**************************************************************

DIMENSIONE MAPPA: size= 41
DIMENSIONE MAPPA: max element = 25
Initializing geometry from GDML file: layout.gdml
G4GDML: Reading 'layout.gdml'...

-------- EEEE ------- G4Exception-START -------- EEEE -------
*** G4Exception : InvalidRead
      issued by : G4GDMLRead::Read()
Unknown tag in gdml: head
*** Fatal Exception *** core dump ***
 **** Track information is not available at this moment
 **** Step information is not available at this moment

-------- EEEE -------- G4Exception-END --------- EEEE -------


*** G4Exception: Aborting execution ***
Aborted (core dumped)

I understand that it’s releated to the layout.gdml file, but I’ve it in the building directory!

Hi @bmorgan.
In these months I used the simulation by ssh connection using the laboratory machine, because they installed HepMC on that machine. To run the simulation I had to write

/cvmfs/sft.cern.ch/lcg/contrib/CMake/3.14.2/Linux-x86_64/bin/cmake -DHEPMC_LIBRARIES=/home/xxxxx/lemmatb/HepMC-2.06.11/build/lib/libHepMC.so -DGeant4_DIR=/cvmfs/geant4.cern.ch/geant4/10.7.p01/x86_64-centos7-gcc8-optdeb-MT/lib64/Geant4-10.7.1/ ../

and it works.

Now I have to revive this topic because I need the visualization and it would be very slow the visualization by ssh.
I installed HepMC and it looks like was sucesfully (I had to modify a file to install HepMC on windows…the HepMC developers helped me to do it). You can see here the installation of HepMC

log_HepMC.txt (697.7 KB)

Then I tried to compile the simulation

I compiled in these way

cmake -DGeant4_DIR=“C:\Program Files\geant4_10_07_p01_install\lib\Geant4-10.7.1” -DHEPMC_INCLUDE_DIR=“C:\HepMC-install\include” -DHEPMC_LIBRARIES=“C:\HepMC-install\lib\HepMCfio.lib” “C:\setup”

but I get this error

error.txt (43.7 KB)

do you know how to fix it?

Thank you

You are getting a bunch of linker errors that look like this:

HepMCG4AsciiReader.obj : error LNK2019: riferimento al simbolo esterno … non risolto nella funzione …

This means that some of your code calls some external function which the linker does not find. The reason seems this:

LINK : warning LNK4044: opzione ‘/LC:/HepMC-install/lib -lHepMCfio’ non riconosciuta; verrà ignorata [C:\setup\build\mainMCMC.vcxproj]

Those options are the ones that would link your code with the HEPMCfio library, but the linker did not recognize it, and hence the library was not included. I think it may be because there is a space; there should be two options (/LC:/HepMC-install/lib and -lHepMCfio) but somehow they ended up as one.

Having a look at FindHEPMC.cmake, I do not think you are supposed to pass explicitly -DHEPMC_LIBRARIES directly to cmake; instead, you pass -DHEPMC_DIR=“C:\HepMC-install" and let FindPackage do its thing.

I am not sure if I could provide a solution, but at least I hope this helped. Good luck!

And if I may, it can be useful to change your language to English, so it easier to share your error logs :slight_smile:

Hello @sergio and thank you

If I don’t pass the libraries, i.e. I compile like this

cmake -DGeant4_DIR="C:\Program Files\geant4_10_07_p01_install\lib\Geant4-10.7.1" -DHEPMC_INCLUDE_DIR="C:\HepMC-install\include" "C:\setup"

I get this error (i.e. it says to pass the libraries)

Could NOT find HepMC (missing: HEPMC_LIBRARIES)

as you can read in the log
log_libraries.txt (2.5 KB)

Sorry, I didn’t understand how shold write …can you write the full compilation command please?

Sorry, I’ve to check how to change the language.

You should not pass -DHEPMC_INCLUDE_DIR either, but -DHEPMC_DIR. FindPackage will try to find HepMC in the directory given by HEPMC_INCLUDE_DIR, and give values to both HEPMC_INCLUDE_DIR and HEPMC_LIBRARIES based on what it found. This is equivalent to how you pass -DGeant4_DIR and not -DGeant4_INCLUDE_DIR. The alternative way is to give both HEPMC_INCLUDE_DIR and HEPMC_LIBRARIES explicitly, but I think that my suggestion should work.

I would try this:

cmake -DGeant4_DIR="C:\Program Files\geant4_10_07_p01_install\lib\Geant4-10.7.1" -DHEPMC_DIR="C:\HepMC-install" "C:\setup"`

Hello @sergio , sorry…I missed your reply!

I’ve just tried to compilet how you suggested, but I get:

TBDetectorConstruction.cc
LINK : warning LNK4044: opzione '/LC:/HepMC-install/lib -lHepMCfio' non riconosciuta; verrà ignorata [C:\setup\build\mainMCMC.vcxproj]
HepMCG4AsciiReader.obj : error LNK2019: riferimento al simbolo esterno "public: __cdecl HepMC::WeightContainer::WeightContainer(class std::ve
ctor<double,class std::allocator<double> > const &)" (??0WeightContainer@HepMC@@QEAA@AEBV?$vector@NV?$allocator@N@std@@@std@@@Z) non risolto
nella funzione "public: class HepMC::GenEvent * __cdecl HepMC::IO_BaseClass::read_next_event(void)" (?read_next_event@IO_BaseClass@HepMC@@QEA
APEAVGenEvent@2@XZ) [C:\setup\build\mainMCMC.vcxproj]
HepMCG4Interface.obj : error LNK2001: simbolo esterno "public: __cdecl HepMC::WeightContainer::WeightContainer(class std::vector<double,class
 std::allocator<double> > const &)" (??0WeightContainer@HepMC@@QEAA@AEBV?$vector@NV?$allocator@N@std@@@std@@@Z) non risolto [C:\setup\build\m
ainMCMC.vcxproj]
HepMCG4AsciiReader.obj : error LNK2019: riferimento al simbolo esterno "enum HepMC::Units::LengthUnit __cdecl HepMC::Units::default_length_un
it(void)" (?default_length_unit@Units@HepMC@@YA?AW4LengthUnit@12@XZ) non risolto nella funzione "public: class HepMC::GenEvent * __cdecl HepM
C::IO_BaseClass::read_next_event(void)" (?read_next_event@IO_BaseClass@HepMC@@QEAAPEAVGenEvent@2@XZ) [C:\setup\build\mainMCMC.vcxproj]
HepMCG4Interface.obj : error LNK2001: simbolo esterno "enum HepMC::Units::LengthUnit __cdecl HepMC::Units::default_length_unit(void)" (?defau
lt_length_unit@Units@HepMC@@YA?AW4LengthUnit@12@XZ) non risolto [C:\setup\build\mainMCMC.vcxproj]
HepMCG4AsciiReader.obj : error LNK2019: riferimento al simbolo esterno "enum HepMC::Units::MomentumUnit __cdecl HepMC::Units::default_momentu
m_unit(void)" (?default_momentum_unit@Units@HepMC@@YA?AW4MomentumUnit@12@XZ) non risolto nella funzione "public: class HepMC::GenEvent * __cd
ecl HepMC::IO_BaseClass::read_next_event(void)" (?read_next_event@IO_BaseClass@HepMC@@QEAAPEAVGenEvent@2@XZ) [C:\setup\build\mainMCMC.vcxproj
]
HepMCG4Interface.obj : error LNK2001: simbolo esterno "enum HepMC::Units::MomentumUnit __cdecl HepMC::Units::default_momentum_unit(void)" (?d
efault_momentum_unit@Units@HepMC@@YA?AW4MomentumUnit@12@XZ) non risolto [C:\setup\build\mainMCMC.vcxproj]
HepMCG4AsciiReader.obj : error LNK2019: riferimento al simbolo esterno "public: __cdecl HepMC::GenEvent::GenEvent(int,int,class HepMC::GenVer
tex *,class HepMC::WeightContainer const &,class std::vector<long,class std::allocator<long> > const &,enum HepMC::Units::MomentumUnit,enum H
epMC::Units::LengthUnit)" (??0GenEvent@HepMC@@QEAA@HHPEAVGenVertex@1@AEBVWeightContainer@1@AEBV?$vector@JV?$allocator@J@std@@@std@@W4Momentum
Unit@Units@1@W4LengthUnit@71@@Z) non risolto nella funzione "public: class HepMC::GenEvent * __cdecl HepMC::IO_BaseClass::read_next_event(voi
d)" (?read_next_event@IO_BaseClass@HepMC@@QEAAPEAVGenEvent@2@XZ) [C:\setup\build\mainMCMC.vcxproj]
HepMCG4Interface.obj : error LNK2001: simbolo esterno "public: __cdecl HepMC::GenEvent::GenEvent(int,int,class HepMC::GenVertex *,class HepMC
::WeightContainer const &,class std::vector<long,class std::allocator<long> > const &,enum HepMC::Units::MomentumUnit,enum HepMC::Units::Leng
thUnit)" (??0GenEvent@HepMC@@QEAA@HHPEAVGenVertex@1@AEBVWeightContainer@1@AEBV?$vector@JV?$allocator@J@std@@@std@@W4MomentumUnit@Units@1@W4Le
ngthUnit@71@@Z) non risolto [C:\setup\build\mainMCMC.vcxproj]
HepMCG4AsciiReader.obj : error LNK2019: riferimento al simbolo esterno "public: void __cdecl HepMC::GenEvent::print(class std::basic_ostream<
char,struct std::char_traits<char> > &)const " (?print@GenEvent@HepMC@@QEBAXAEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z) non risolto
nella funzione "protected: virtual class HepMC::GenEvent * __cdecl HepMCG4AsciiReader::GenerateHepMCEvent(void)" (?GenerateHepMCEvent@HepMCG4
AsciiReader@@MEAAPEAVGenEvent@HepMC@@XZ) [C:\setup\build\mainMCMC.vcxproj]
HepMCG4AsciiReader.obj : error LNK2019: riferimento al simbolo esterno "public: __cdecl HepMC::IO_GenEvent::IO_GenEvent(class std::basic_stri
ng<char,struct std::char_traits<char>,class std::allocator<char> > const &,int)" (??0IO_GenEvent@HepMC@@QEAA@AEBV?$basic_string@DU?$char_trai
ts@D@std@@V?$allocator@D@2@@std@@H@Z) non risolto nella funzione "public: __cdecl HepMCG4AsciiReader::HepMCG4AsciiReader(class G4String)" (??
0HepMCG4AsciiReader@@QEAA@VG4String@@@Z) [C:\setup\build\mainMCMC.vcxproj]
HepMCG4Interface.obj : error LNK2019: riferimento al simbolo esterno "public: __cdecl HepMC::GenVertex::particle_iterator::particle_iterator(
void)" (??0particle_iterator@GenVertex@HepMC@@QEAA@XZ) non risolto nella funzione "protected: void __cdecl HepMCG4Interface::HepMC2G4(class H
epMC::GenEvent const *,class G4Event *)" (?HepMC2G4@HepMCG4Interface@@IEAAXPEBVGenEvent@HepMC@@PEAVG4Event@@@Z) [C:\setup\build\mainMCMC.vcxp
roj]
HepMCG4Interface.obj : error LNK2019: riferimento al simbolo esterno "public: __cdecl HepMC::GenVertex::particle_iterator::particle_iterator(
class HepMC::GenVertex &,enum HepMC::IteratorRange)" (??0particle_iterator@GenVertex@HepMC@@QEAA@AEAV12@W4IteratorRange@2@@Z) non risolto nel
la funzione "protected: void __cdecl HepMCG4Interface::HepMC2G4(class HepMC::GenEvent const *,class G4Event *)" (?HepMC2G4@HepMCG4Interface@@
IEAAXPEBVGenEvent@HepMC@@PEAVG4Event@@@Z) [C:\setup\build\mainMCMC.vcxproj]
HepMCG4Interface.obj : error LNK2019: riferimento al simbolo esterno "public: virtual __cdecl HepMC::GenVertex::particle_iterator::~particle_
iterator(void)" (??1particle_iterator@GenVertex@HepMC@@UEAA@XZ) non risolto nella funzione "protected: void __cdecl HepMCG4Interface::HepMC2G
4(class HepMC::GenEvent const *,class G4Event *)" (?HepMC2G4@HepMCG4Interface@@IEAAXPEBVGenEvent@HepMC@@PEAVG4Event@@@Z) [C:\setup\build\main
MCMC.vcxproj]
HepMCG4Interface.obj : error LNK2019: riferimento al simbolo esterno "public: class HepMC::GenParticle * __cdecl HepMC::GenVertex::particle_i
terator::operator*(void)const " (??Dparticle_iterator@GenVertex@HepMC@@QEBAPEAVGenParticle@2@XZ) non risolto nella funzione "protected: void
__cdecl HepMCG4Interface::HepMC2G4(class HepMC::GenEvent const *,class G4Event *)" (?HepMC2G4@HepMCG4Interface@@IEAAXPEBVGenEvent@HepMC@@PEAV
G4Event@@@Z) [C:\setup\build\mainMCMC.vcxproj]
HepMCG4Interface.obj : error LNK2019: riferimento al simbolo esterno "public: class HepMC::GenVertex::particle_iterator & __cdecl HepMC::GenV
ertex::particle_iterator::operator++(void)" (??Eparticle_iterator@GenVertex@HepMC@@QEAAAEAV012@XZ) non risolto nella funzione "protected: voi
d __cdecl HepMCG4Interface::HepMC2G4(class HepMC::GenEvent const *,class G4Event *)" (?HepMC2G4@HepMCG4Interface@@IEAAXPEBVGenEvent@HepMC@@PE
AVG4Event@@@Z) [C:\setup\build\mainMCMC.vcxproj]
C:\HepMC-install\lib\HepMC.lib : warning LNK4272: il tipo 'x86' del computer della libreria è in conflitto con il tipo 'x64' del computer di
destinazione [C:\setup\build\mainMCMC.vcxproj]
C:\setup\build\Release\mainMCMC.exe : fatal error LNK1120: 11 esterni non risolti [C:\setup\build\mainMCMC.vcxproj]

C:\setup\build>

Here the full log

log.txt (43.2 KB)

There’s still the same warning:

LINK : warning LNK4044: opzione '/LC:/HepMC-install/lib -lHepMCfio' non riconosciuta; verrà ignorata [C:\setup\build\mainMCMC.vcxproj]
HepMCG4AsciiReader.obj : error LNK2019: riferimento al simbolo esterno "public: __cdecl HepMC::WeightContainer::WeightContainer(class std::ve
ctor<double,class std::allocator<double> > const &)" (??0WeightContainer@HepMC@@QEAA@AEBV?$vector@NV?$allocator@N@std@@@std@@@Z) non risolto
nella funzione "public: class HepMC::GenEvent * __cdecl HepMC::IO_BaseClass::read_next_event(void)" (?read_next_event@IO_BaseClass@HepMC@@QEA
APEAVGenEvent@2@XZ) [C:\setup\build\mainMCMC.vcxproj]

Which directly leads to the linking error I explained earlier.

As I said, FindHepMC.cmake seems to have a bug in this line:

set(HEPMC_FIO_LIBRARIES “-L${HEPMC_LIBRARY_DIR} -lHepMCfio”)

This works fine on Linux, but not on Windows.

I see multiple problems with the FindHepMC.cmake that is shipped with Geant4. Did you manage to build any of the HepMC examples on Windows? Because it does not look possible to me.

To address your current problem, you could try replacing FindHepMC.cmake with this modified version:

# in a directory defined via  HEPMC_ROOT_DIR or HEPMC_DIR environment variable
# Defines:
#
#  HEPMC_FOUND
#  HEPMC_INCLUDE_DIR
#  HEPMC_INCLUDE_DIRS (not cached)
#  HEPMC_LIBRARIES
#  HEPMC_FIO_LIBRARIES

find_path(HEPMC_INCLUDE_DIR HepMC/GenEvent.h
          HINTS $ENV{HEPMC_ROOT_DIR}/include ${HEPMC_ROOT_DIR}/include
          $ENV{HEPMC_DIR}/include ${HEPMC_DIR}/include)

find_library(HEPMC_LIBRARIES NAMES HepMC
             HINTS $ENV{HEPMC_ROOT_DIR}/lib ${HEPMC_ROOT_DIR}/lib
             HINTS $ENV{HEPMC_DIR}/lib ${HEPMC_DIR}/lib)

get_filename_component(HEPMC_LIBRARY_DIR ${HEPMC_LIBRARIES} PATH)

find_library(HEPMC_FIO_LIBRARIES NAMES HepMCfio
             HINTS $ENV{HEPMC_ROOT_DIR}/lib ${HEPMC_ROOT_DIR}/lib
             HINTS $ENV{HEPMC_DIR}/lib ${HEPMC_DIR}/lib)

set(HEPMC_INCLUDE_DIRS ${HEPMC_INCLUDE_DIR})

# handle the QUIETLY and REQUIRED arguments and set HEPMC_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(HepMC DEFAULT_MSG HEPMC_INCLUDE_DIR HEPMC_LIBRARIES HEPMC_FIO_LIBRARIES)

mark_as_advanced(HEPMC_FOUND HEPMC_INCLUDE_DIR HEPMC_LIBRARIES)

Let me know if that works. Pinging @kmura, in case the examples need to be fixed for Windows. I wonder what’s the status with HepMC, since they should be the ones providing the CMake config package.

Hello @sergio , it isn’t a Geant4 example. It’s a Test Beam setup simulation (here the source WeTransfer) and I can’t find FindHepMC.cmake in the source.
I’ve only Cmakelist where HepMC is searched by

find_package(HepMC REQUIRED)
include_directories(${PROJECT_SOURCE_DIR}/include 
                    ${PROJECT_SOURCE_DIR}/process_channeling/include 
                    ${Geant4_INCLUDE_DIR}
                    ${HEPMC_INCLUDE_DIR} )
target_link_libraries(mainMCMC ${Geant4_LIBRARIES} 
                      ${HEPMC_LIBRARIES} 
                      ${HEPMC_FIO_LIBRARIES} ${PYTHIA6_LIBRARIES} )

should I add these lines

in the Cmakelist?

Thank you

I am pretty confident that your simulation is based on one of Geant4 HepMC examples. This line

find_package(HepMC REQUIRED)

uses a FindHepMC.cmake file under the hood, which is shipped with Geant4 to support those examples.

If you check the CMake log that you posted on your first message, you can see that you are using it:

This is the file you can try modifying C:/Program Files/geant4_10_07_p01_install/lib/Geant4-10.7.1/Modules/FindHepMC.cmake.

Could you please try to build those examples, before and after modifying the file? It would be nice to know if there is a problem on Windows that needs fixing.

Hello @sergio

First I tried to compile the examples

  1. examples\extended\eventgenerator\HepMC\HepMCEx01 , but I got error

log_HepMCEx01.txt (9.7 KB)

2.examples\extended\eventgenerator\HepMC\HepMCEx02 , but I got error

log_HepMCEx02.txt (9.3 KB)

It looks like to me they are the same errors of the Test Beam simulation.

Then I modified the

C:/Program Files/geant4_10_07_p01_install/lib/Geant4-10.7.1/Modules/FindHepMC.cmake .

FindHepMC.cmake.txt (1.1 KB)

and I compiled the Test beam simulation and the example, but still getting errors

log_setup.txt (43.7 KB)

log_HepMCEx01_2.txt (10.6 KB)

log_HepMCEx02_2.txt (9.7 KB)

1 Like