c++xcodegeant4

Having trouble with XCode: nullptr_t error


I am new to XCode and doing my first project for a simulation software called Geant4. I have the below code in C++ and when I run it I keep getting this error:

error: member 'nullptr_t' declared as a template 
_LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(__value_init_tag(), __value_init_tag()) {}

The code below includes a CMakeLists.txt file and a sim.cc file. The issue seems to be coming from the sim.cc file. I did some reading and it seems to be an issue with my version of XCode (14.3). I tried adding the path to iostream but that did not fix the issue.

Does anyone have any recommendations about how to fix this problem?

CMakeLists.txt

cmake_minimum_required(VERSION 3.16...3.21 FATAL_ERROR)

project(Simulation)

find_package(Geant4 REQUIRED ui_all vis_all)

include(${Geant4_USE_FILE})

file(GLOB sources ${PROJECT_SOURCE_DIR}/*.cc)
file(GLOB headers ${PROJECT_SOURCE_DIR}/*.hh)

add_executable(sim sim.cc ${sources} ${headers})
target_link_libraries(sim ${Geant4_LIBRARIES})

add_custom_target(Simulation DEPENDS sim)

sim.cc

#include <iostream>

#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "G4VisManager.hh"
#include "G4VisExecutive.hh"
#include "G4UIExecutive.hh"

int main(int argc, char** argv){
    G4RunManager *runManager = new G4RunManager();
    
    G4UIExecutive *ui = new G4UIExecutive(argc, argv);
    
    G4VisManager *visManager = new G4VisExecutive();
    visManager->Initialize();
    
    G4UImanager *UImanager = G4UImanager::GetUIpointer();
    
    ui->SessionStart();
    
    return 0;
}

Solution

  • I successfully reinstalled Geant4 following these instructions. There seemed to be a compiler issue and Geant4 did not have the correct file paths. The sample code above now runs with no changes to the code.