Message: Re: CRY and GEANT4 linking problem Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Note Re: CRY and GEANT4 linking problem 

Forum: Installation and Configuration
Re: Question CRY and GEANT4 linking problem (Dung Phan)
Date: 19 Aug, 2016
From: Ben Morgan <Ben Morgan>

On Mon, 08 Aug 2016 21:47:03 GMT, Dung Phan wrote:
> I have a simulation that uses CRY to simulate the cosmic ray effects. I, therefore, installed CRY and tried modifying the CMakeList.txt by adding:
> 
> include_directories(${PROJECT_SOURCE_DIR}/include
>                     ${Geant4_INCLUDE_DIR}
>                     /media/dphan/EXT4/SciWorkSpace/CRYv1.7/src #--> location of CRY's header files
>                     /home/dphan/ROOT-system/root-5.34.34/include) #--> my ROOT location
> file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cc)
> file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hh)
> file(GLOB headers /media/dphan/EXT4/SciWorkSpace/CRYv1.7/src/*.h)
> file(GLOB headers /home/dphan/ROOT-system/root-5.34.34/include/*.h)
> 
> when I compile the code, I got this error. I think this is a linking error.
> 
> CMakeFiles/LXe.dir/src/LXeDetectorConstruction.cc.o: In function `_GLOBAL__sub_I_LXeDetectorConstruction.cc':
> /home/dphan/ROOT-system/root-5.34.34/include/TVersionCheck.h:34: undefined reference to `TVersionCheck::TVersionCheck(int)'
> CMakeFiles/LXe.dir/src/LXePrimaryGeneratorAction.cc.o: In function `LXePrimaryGeneratorAction::GeneratePrimaries(G4Event*)':
> /media/dphan/EXT4/Geant4.9.6/SimulationDir/chips/chips/src/LXePrimaryGeneratorAction.cc:197: undefined reference to `CRYGenerator::genEvent(std::vector >*)'
> /media/dphan/EXT4/Geant4.9.6/SimulationDir/chips/chips/src/LXePrimaryGeneratorAction.cc:213: undefined reference to `CRYUtils::partName(CRYParticle::CRYId)'
> /media/dphan/EXT4/Geant4.9.6/SimulationDir/chips/chips/src/LXePrimaryGeneratorAction.cc:245: undefined reference to `CRYParticle::PDGid()'
> CMakeFiles/LXe.dir/src/LXePrimaryGeneratorAction.cc.o: In function `LXePrimaryGeneratorAction::LXePrimaryGeneratorAction(char const*)':
> /media/dphan/EXT4/Geant4.9.6/SimulationDir/chips/chips/src/LXePrimaryGeneratorAction.cc:78: undefined reference to `CRYSetup::CRYSetup(std::string, std::string)'
> /media/dphan/EXT4/Geant4.9.6/SimulationDir/chips/chips/src/LXePrimaryGeneratorAction.cc:80: undefined reference to `CRYGenerator::CRYGenerator(CRYSetup*)'
> CMakeFiles/LXe.dir/src/LXePrimaryGeneratorAction.cc.o: In function `LXePrimaryGeneratorAction::UpdateCRY(std::string*)':
> /media/dphan/EXT4/Geant4.9.6/SimulationDir/chips/chips/src/LXePrimaryGeneratorAction.cc:135: undefined reference to `CRYSetup::CRYSetup(std::string, std::string)'
> /media/dphan/EXT4/Geant4.9.6/SimulationDir/chips/chips/src/LXePrimaryGeneratorAction.cc:137: undefined reference to `CRYGenerator::CRYGenerator(CRYSetup*)'
> CMakeFiles/LXe.dir/src/LXePrimaryGeneratorAction.cc.o: In function `LXePrimaryGeneratorAction::CRYFromFile(G4String)':
> /media/dphan/EXT4/Geant4.9.6/SimulationDir/chips/chips/src/LXePrimaryGeneratorAction.cc:168: undefined reference to `CRYSetup::CRYSetup(std::string, std::string)'
> /media/dphan/EXT4/Geant4.9.6/SimulationDir/chips/chips/src/LXePrimaryGeneratorAction.cc:170: undefined reference to `CRYGenerator::CRYGenerator(CRYSetup*)'
> 
> How can I overcome this mess?
> Thank you in advance!
> 

It looks like the end executable/library is not getting linked to the ROOT and CRY libraries. You don't need to file(GLOB ...) the ROOT and CRY headers, but you do need to link the libraries. See the extended example "AnaEx02": http://geant4.web.cern.ch/geant4/UserDocumentation/Doxygen/examples_doc/html/ExampleAnaEx02.html for an example cmake script that uses ROOT (NB: you should install ROOT using its CMake build system for the easiest integration with CMake). For CRY, I'm assuming it does not provide a "FindCry.cmake" or "CRYConfig.cmake" file, so in this case, you can use/link to it by doing (using your paths):

set(CRY_INCLUDE_DIRS /media/dphan/EXT4/SciWorkSpace/CRYv1.7/src)

# This is speculative as I don't know what CRY's library is actually named - add the appropriate full path
set(CRY_LIBRARIES /media/dphan/EXT4/SciWorkSpace/CRYv1.7/src/src/libCRY.so)

include_directories(${CRY_INCLUDE_DIRS})

# Build your exe...

# then link it, adapt names to whatever your exe is called
target_link_libraries(yourexe ${CRY_LIBRARIES})

As noted in the above adapt the full path(s) to the CRY library(ies) as appropriate.

See also the CMake tutorial and Reference Manual for further info on setting/using include paths and linking.

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 None: Re: CRY and GEANT4 linking problem   (Dung Phan - 02 Oct, 2016)
 Add Message Add Message
to: "Re: CRY and GEANT4 linking problem"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]