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

From: Mikhail Polkovnikov <pmk_at_ihep.ru>
Date: Fri, 8 Feb 2019 18:23:30 +0300

Dear Enrico,

ROOT file is rather simple and can be compiled by ROOT5 as well.

Input file uses DETECT card and MGDRAW user routine to measure energy
deposition to NaI target material.

Just extract files in a one directory and run Makefile. If compilation
will be successful then run script RunMe.sh. This scrips is required to
add current project directory to LD_LIBRARY_PATH for proper link and run.

As a result root file must contain TCanvas and TH1D of energy deposition
spectrum, same as a DETECT card.


Best regards,
Mikhail



On 08.02.2019 17:12, Enrico Scomparin wrote:
> Dear Francesc, Giuseppe, Mikhail,
>
> thanks a lot for the fast feedback and the suggestions!
>
> _at_Giuseppe: I also had the feeling that  the procedure could be
> severely system/ROOT-dependent. The point is that we have quite some
> code in our project that we would like to re-use and this was
> considered as a rather practical solution. We will still work on that
> and report on progress, if any. Thanks also for pointing me to ldpmqmd.
>
> _at_Mikhail: even if I am currently using ROOT5, I would be glad if you
> can send me your working example, it will possibly be useful.
>
> Best
>
> Enrico
>
> On 08/02/19 13:43, Mikhail Polkovnikov <Михаил Полковников> wrote:
>> Dear Enrico,
>>
>> I can send you a small working example, based on the example from
>> FLUKA site, with Makefile how to compile and link FLUKA object files
>> and ROOT/С++ object files. I don't use classes derived from TObject,
>> so if you are going to use standard ROOT classes and objects, it
>> might be helpful.
>>
>> I'm using ROOT-6.08.06 and GCC 8.2.0 multilib.
>>
>>
>> Best regards,
>> Mikhail
>>
>>
>> On 07.02.2019 20:50, Enrico Scomparin wrote:
>>> Dear experts,
>>>
>>> I am relatively new to Fluka and I am trying to follow the
>>> guidelines given in
>>>
>>> http://www.fluka.org/fluka.php?id=examples&sub=example3&node=4
>>>
>>> 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 (
>>> http://www.fluka.org/content/examples/Makefile ) 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/libCore.so.5:
>>> 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 rootfluka.map fluka.o dlornbck.o
>>> source_interface.o stuprf.o magfld.o mgdraw.o FluLib.o libResults.so
>>> -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
>>> https://www.fluka.org/fluka.php?id=acc_info
>>




__________________________________________________________________________
You can manage unsubscription from this mailing list at https://www.fluka.org/fluka.php?id=acc_info

Received on Fri Feb 08 2019 - 17:39:36 CET

This archive was generated by hypermail 2.3.0 : Fri Feb 08 2019 - 17:39:39 CET