Saving the output as root file

Hello everyone!
I am trying to save the output of fluka simulation in the root file for further analysis. I followed instructions on the fluka website http://www.fluka.org/fluka.php?id=examples&sub=example3&node=4. In step 5, it says, “Compile the C++ part of the code using a Makefile”. when I try to make it gives me the error below.

Generating Library FluLib.o...
g++ -c FluLib.cpp -pthread -std=c++17 -m64 -I/usr/include/ROOT
In file included from FluLib.cpp:2:
/usr/include/ROOT/cfortran.h:223:3: error: #error "cfortran.h:  Can't find your environment among:    - GNU gcc (g77) on Linux.- MIPS cc and f77 2.0. (e.g. Silicon Graphics, DECstations, ...)  - IBM AIX XL C and FORTRAN Compiler/6000 Version 01.01.0000.0000 - VAX   VMS CC 3.1 and FORTRAN 5.4. - Alpha VMS DEC C 1.3 and DEC FORTRAN 6.0.- Alpha OSF DEC C and DEC Fortran for OSF/1 AXP Version 1.2 - Apollo DomainOS 10.2 (sys5.3) with f77 10.7 and cc 6.7. - CRAY - NEC SX-4 SUPER-UX - CONVEX - Sun - PowerStation Fortran with Visual C++  - HP9000s300/s700/s800 Latest test with: HP-UX A.08.07 A 9000/730 - LynxOS: cc or gcc with f2c. -VAXUltrix: vcc,cc or gcc with f2c. gcc or cc with f77.  -  f77 with vcc works; but missing link magic for f77 I/O. - NO fort. None of gcc, cc or vcc generate required names.    - f2c/g77:   Use #define    f2cFortran, or cc -Df2cFortran  - gfortran:  Use #define    gFortran,   or cc -DgFortran(also necessary for g77 with -fno-f2c option) - NAG f90: Use #define NAGf90Fortran, or cc - DNAGf90Fortran  - Absoft UNIX F77: Use #define AbsoftUNIXFortran or cc -DAbsoftUNIXFortra - Absoft Pro Fortran: Use #define AbsoftProFortran     - Portland Group Fortran: Use #define pgiFortran - Intel Fortran: Use #define INTEL_COMPILER"
  223 |  #error "cfortran.h:  Can't find your environment among:\
      |   ^~~~~
make: *** [makefile:55: FluLib.o] Error 1

I am not sure how to solve this.
Do you have any idea, how to fix this issue?
Thank you for your time.

Dear @Iftikhar ,

I assume you have a Linux system.

It looks like you miss the package “cfortran”.
You should install it with your package manager.

Hope this could help.

Hi,
Thank you. I added this cfortran package, however now I have another problem when I try to compile using make. The error is given below.

/usr/bin/ld: FluLib.o: undefined reference to symbol '_ZN7TObjectdlEPv'
/usr/bin/ld: /lib/x86_64-linux-gnu/libCore.so.6.22: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

I am not able to fix this problem. Your help will be highly appreciated.
Thank you

Hi @Iftikhar ,
can you provide the code?
You can also send me privately to luillo@cern.ch.

Let me add a personal note. This problem is likely related to the linking against ROOT library.
Although one could find convenient to directly write directly in a ROOT structure the output of the FLUKA simulation, I’m not sure that in the long term this is the most efficient way since the interfaces should be adapted and the maintenance might be time-consuming.
My preferred approach is to write FLUKA results into ASCII structures and then convert to my favourite data structure in a second step.

Cheers Luigi

Dear @Iftikhar ,

as written you privately, this forum gives support only to FLUKA distributed by CERN.

This tarball (5.1 KB) contains the files modified to produce a ROOT file.
The main modification is in the Makefile at linking stage.
At running time, the environment variable LD_LIBRARY_PATH must include the path where libResults.so is.

I tested the executable on Fedora 33 with ROOT 6.22/06.

Let us know in case you have further questions.

Cheers Luigi

Hello Luigi,
Thank you for your help. I am struggling with how to compile it. I already added the files you send me to my directory
I do the following as shown on the fluka website, the link I shared previously.
These are the steps

  1. I run this command $FLUPRO/flutil/lfluka -m fluka usrini.o usrout.o histin.o mgdraw.o FluLib.o libResults.so -o rootfluka.
  2. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/root-path/lib:pwd
  3. FLUTIL/rfluka -e rootfluka -N0 -M1 root.inp

However, I am not getting the results that you sent me.
Can you please show the commands that you used to have the root file. Sorry for asking too many things.
Thank you very much

Cheers,
Iftikhar

Hello @Iftikhar ,

as already said, this forum provides support only to the FLUKA version distributed by CERN.
It can be download it from here.

These are the steps to follow:

  1. export PATH=<path_to_FLUKA>/bin/:$PATH # to find fluka-config
  2. compile with the command make
  3. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:root-config --libdir:pwd
  4. rfluka -e rootfluka -M1 root.inp

Hope this can help.
Cheers Luigi