I am new to C++ and XML and i am using cmake to compile some GEANT4 codes. after the command "make, there seems to a problem with linking the CXX executable
I am running it on Mac OSX10.14.6, geant4 10.5, The C/CXX compiler identification is AppleClang 10.0.1.10010046
This is the code which links the XML part.
XMLConfiguration* Cfg = new XMLConfiguration("mammact");
Cfg->readFile("mammact.xml");
When i remove all the XML part related to the code from the main.cc,include and src, i can run it. But when i include the XML part, the following errors appear;
[100%] Linking CXX executable mammactcone
Undefined symbols for architecture x86_64:
"xercesc_3_2::XMLPlatformUtils::Initialize(char const*, char const*, xercesc_3_2::PanicHandler*, xercesc_3_2::MemoryManager*)", referenced from:
XMLConfiguration::XMLConfiguration(char const*) in XMLConfiguration.cc.o
.
.
.
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Since i am new to programming, I'm learning things as i'm coding, so i kindly request you to provide solutions/suggestion a bit clear than how you would do to a fellow prorgrammer :)
This is my CMakeLists.txt:
cmake_minimum_required(VERSION 2.8.12)
project(SimulationMAMA)
find_package(MPI REQUIRED)
#-------------------------------------------------------------------------
# Find Geant4 package, activating all available UI and Vis drivers by default
# You can set WITH_GEANT4_UIVIS to OFF via the command line or ccmake/cmake-gui
# to build a batch mode only executable
#
option(WITH_GEANT4_UIVIS "Build example with Geant4 UI and Vis drivers" ON)
if(WITH_GEANT4_UIVIS)
find_package(Geant4 REQUIRED ui_all vis_all)
else()
find_package(Geant4 REQUIRED)
endif()
find_package(G4mpi REQUIRED)
#-------------------------------------------------------------------------
# Setup Geant4 include directories and compile definitions
# Setup include directory for this project
#
include(${Geant4_USE_FILE})
include_directories(${PROJECT_SOURCE_DIR}/include)
#-------------------------------------------------------------------------
# Locate sources and headers for this project
# NB: headers are included so they will show up in IDEs
#
file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cc)
file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hh)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include
${Geant4_INCLUDE_DIR}
${G4mpi_INCLUDE_DIR}
${Xerces_INCLUDE_DIR})
#-------------------------------------------------------------------------
# Add the executable, and link it to the Geant4 libraries
#
add_executable(mammactcone mammactcone.cc ${sources} ${headers})
target_link_libraries(mammactcone ${Geant4_LIBRARIES})
#-------------------------------------------------------------------------
# Copy scripts to the build directory of XRFCT.
#
set(MY_SCRIPTS
mammact.xml init_vis.mac vis.mac run1.mac
)
foreach(_script ${MY_SCRIPTS})
configure_file(
${PROJECT_SOURCE_DIR}/${_script}
${PROJECT_BINARY_DIR}/${_script}
COPYONLY
)
endforeach()
#set(CMAKE_INCLUDE_CURRENT_DIR ON)
#set(CMAKE_AUTOMOC ON)
#find_package(Qt5Core)
#add_executable(${PROJECT_NAME} "mammactcone.cc")
#target_link_libraries(${PROJECT_NAME} Qt5::Core)
#-------------------------------------------------------------------------
# For internal Geant4 use - but has no effect if you build this
# example standalone
#
#add_custom_target(mammactcone DEPENDS mammactcone)
#-------------------------------------------------------------------------
# Install the executable to 'bin' directory under CMAKE_INSTALL_PREFIX
install(TARGETS mammactcone DESTINATION bin)