Sorry, I still can’t find the solution. Could you please point out some useful posts?
Thank you so much!
PS: When I run it using .x simulate.cc
It becomes:
IncrementalExecutor::executeFunction: symbol '__clang_call_terminate' unresolved while linking function '_GLOBAL__sub_I_cling_module_56'!
Generating stack trace...
0x00007f2ccea3559e in <unknown> from /home/root/lib/libCling.so
0x00007f2cce9bd303 in <unknown> from /home/root/lib/libCling.so
0x00007f2cce9bda43 in <unknown> from /home/root/lib/libCling.so
0x00007f2ccea8cd3a in <unknown> from /home/root/lib/libCling.so
0x00007f2ccea9b4f5 in <unknown> from /home/root/lib/libCling.so
0x00007f2ccea9cf38 in <unknown> from /home/root/lib/libCling.so
0x00007f2ccea85cd0 in <unknown> from /home/root/lib/libCling.so
0x00007f2cce8d3b9c in <unknown> from /home/root/lib/libCling.so
0x00007f2cce8ef366 in TCling::ProcessLine(char const*, TInterpreter::EErrorCode*) + 0x1126 from /home/root/lib/libCling.so
0x00007f2cce8ef6fb in TCling::ProcessLineSynch(char const*, TInterpreter::EErrorCode*) + 0xeb from /home/root/lib/libCling.so
0x00007f2cd2f8e9d5 in TApplication::ExecuteFile(char const*, int*, bool) at TApplication.cxx:? from /home/root/lib/libCore.so.6.26
0x00007f2cd33b02e0 in TRint::ProcessLineNr(char const*, char const*, int*) + 0x60 from /home/root/lib/libRint.so.6.26
0x00007f2cd33b07fa in TRint::HandleTermInput() + 0x24a from /home/root/lib/libRint.so.6.26
0x00007f2cd30ea4fc in TUnixSystem::CheckDescriptors() + 0x9c from /home/root/lib/libCore.so.6.26
0x00007f2cd30ec338 in TUnixSystem::DispatchOneEvent(bool) + 0x578 from /home/root/lib/libCore.so.6.26
0x00007f2cd2ff6527 in TSystem::Run() + 0xe7 from /home/root/lib/libCore.so.6.26
0x00007f2cd2f8c897 in TApplication::Run(bool) + 0x27 from /home/root/lib/libCore.so.6.26
0x00007f2cd33b238b in TRint::Run(bool) + 0x4bb from /home/root/lib/libRint.so.6.26
0x0000564457c952f3 in main + 0x53 from /home/root/bin/root.exe
0x00007f2cd2985d90 in <unknown> from /lib/x86_64-linux-gnu/libc.so.6
0x00007f2cd2985e40 in __libc_start_main + 0x80 from /lib/x86_64-linux-gnu/libc.so.6
0x0000564457c95345 in _start + 0x25 from /home/root/bin/root.exe
Error in <HandleInterpreterException>: Trying to dereference null pointer or trying to call routine taking non-null arguments.
Execution of your code was aborted.
In file included from input_line_10:1:
/home/mdr/simulate.cc:52:21: warning: null passed to a callee that requires a non-null argument [-Wnonnull]
double energyInc = gr->Uniform(5, 10);
I wasn’t able to reproduce this locally. In principle, the code looks okay.
I think the problem might come from your environment. How did you installed ROOT (i.e. did you build yourself, via precompiled package, etc.)? Are you getting similar errors with other macro files?