Re: [fluka-discuss]: problem with use of external C/C++ library

From: Giuseppe Battistoni <>
Date: Fri, 8 Feb 2019 09:56:56 +0100

Hi Enrico
that example (originated by me) is quite old and should be updated.
However it turned out that the matter is not "universal", in the sense
that there is a strong dependence on the Root version and installation,
the Linux distribution and version, the compiler version (and the match
among these elements). Therefore it was difficult to give
a robust example. For instance, I develop things in Fedora, and often
there are differences with respect to Ubuntu and proper tweaks have to
be found.

First of all I notice one thing that has nothing to do with root
but it should be probably changed in your case: the Makefile
invokes the linking script lfluka ($(FLUPRO)/flutil/lfluka -o $_at_ -m
fluka $?)
It's better (and mandatory if you are going to perform nucleus-nucleus
interactions!) to use ldpmqmd instead of lfluka. It calls lfluka but
links to the relevant nucleus-nucleus libraries.

Other users which were interested to this approach either modified the
Makefile or created an "ad hoc" version of ldpmqmd or lfluka to be used
in this context in order to insert other qualifiers

For all these reasons of stability and lack of universality, many of us
preferred to give up the idea of linking directly Fluka to Root, using
instead two step procedures in which a custom post-process converts user
output file to a Root file.

On 07/02/2019 18:50, Enrico Scomparin wrote:
> Dear experts,
> I am relatively new to Fluka and I am trying to follow the guidelines
> given in
> in order to use a C function, containing ROOT classes, that I then call
> inside my source.f . I am working on a Linux machine (Ubuntu 16.04).
> With minimal adaptations of the makefile that can be found there (
> ) I can compile both the
> fortran routines and the C code. However when the makefile invokes
> lfluka I am getting an error.
> More in detail, the error message is
> /usr/bin/ld: FluLib.o: undefined reference to symbol '_ZN7TObjectdlEPv'
> /home/scompar/alice/sw/ubuntu1604_x86-64/ROOT/v5-34-30-alice9-1/lib/
> error adding symbols: DSO missing from command line
> which seems related to ROOT. Indeed if I take the link command as
> created by lfluka
> gfortran -msse2 -mfpmath=sse -fPIC -O3 -g -mtune=generic
> -fexpensive-optimizations -funroll-loops -fstrength-reduce -Wall
> -Wuninitialized -Wno-tabs -Wline-truncation -Wno-unused-function
> -Wno-unused-parameter -Wno-unused-dummy-argument -Wno-unused-variable
> -Wno-conversion -Wunused-label -Waggregate-return -Wcast-align
> -Wsystem-headers -ftrapping-math -frange-check -fbackslash -fdump-core
> -fbacktrace -ffpe-trap=invalid,zero,overflow -finit-local-zero
> -ffixed-form -frecord-marker=4 -funderscoring -fno-automatic
> -fd-lines-as-comments -fbounds-check
> -I/home/scompar/cernbox/Documents/Fluka/flukapro -v -o rootfluka
> -Xlinker -Map -Xlinker fluka.o dlornbck.o
> source_interface.o stuprf.o magfld.o mgdraw.o FluLib.o
> -L/home/scompar/cernbox/Documents/Fluka -lflukahp -l gfortran -l m
> -shared-libgcc
> I append by hand at the end  `root-config --glibs` -lstdc++ , and I
> execute it as such, then everything works [1]. However I find no simple
> way to have these two further instructions to be "generated" by the
> lfluka command.
> Is there a way to add qualifiers to lfluka in such a way that the link
> command contains this further information ? Of course any other
> alternative solution would be also welcome!
> Thanks and best regards
> Enrico
> [1] In order for the link command to work I also have to run,
> immediately before, the line 'ar x
> /home/scompar/cernbox/Documents/Fluka/libflukahp.a fluka.o' , to extract
> fluka.o
> __________________________________________________________________________
> You can manage unsubscription from this mailing list at

via Sommarive 14, 38123 Povo, Trento
tel: +39 0461 283294
INFN Sezione di Milano
via Celoria 16, 20133 Milano
tel: +39 02 50317307
You can manage unsubscription from this mailing list at
Received on Fri Feb 08 2019 - 11:10:24 CET

This archive was generated by hypermail 2.3.0 : Fri Feb 08 2019 - 11:10:26 CET