How to link a program with ROOT's automatically generated libraries?

Dear experts,
how can I link my program to library generated with the command:

RooClassFactory::makePdfInstance("AngleS",...);

The command creates the following files:

RooAngleSPdf.cxx
RooAngleSPdf.h
RooAngleSPdf_cxx.d
RooAngleSPdf_cxx.so
RooAngleSPdf_cxx_ACLiC_dict_rdict.pcm

How can then compile another program that links this library ?
in clang++ the option
.L . -l:$(wildcard *_cxx.so)
does not work.

Many thanks for your support.
Kind regards,

  • Mauro.

Hi Mauro,

there are several ways to tackle this.
I don’t think the usage of wildcards is possible in link statements. On the other hand you can load all of your libraries with a several gSystem->Load(myLibName) statements.
Or, alternatively, build a string with all the names of the libraries and then use gInterpreter->ProcessLine(…) to execute it.

Cheers,
D

Hi,
maybe I didn’t mention an important point, I’m not using CINT, I’m using compiled code.

I tried your solution but then when I run the makefile I get the following message:

clang++ -ansi -pedantic -Wall -Wextra -m64 -O3 -o ExtractYieldroot-config --cflags --glibs-lMinuit -lRooFit -lRooFitCore -lFoam -I ../interface ../src/B0KstMuMuSingleCandTreeContent.cc ../src/B0KstMuMuTreeContent.cc ../src/ReadParameters.cc ../src/Utils.cc -D"ROOFIT" ExtractYield.cc Undefined symbols for architecture x86_64: "vtable for RooAngleSPdf", referenced from: RooAngleSPdf::RooAngleSPdf() in ExtractYield-b47b4f.o NOTE: a missing vtable usually means the first non-inline virtual member function has no definition. "vtable for Roo_AngleSPdf", referenced from: Roo_AngleSPdf::Roo_AngleSPdf() in ExtractYield-b47b4f.o NOTE: a missing vtable usually means the first non-inline virtual member function has no definition. ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [ExtractYield] Error 1

At compile time the compiler doesn’t knot that I’ll load the library with gSystem->Load(myLibName).

Many thanks for your support.
Kind regards,

  • Mauro.

Hi,

What about

clang++  -ansi -pedantic -Wall -Wextra -m64 -O3 -o ExtractYield -I ../interface ../src/B0KstMuMuSingleCandTreeContent.cc RooAngleSPdf.cxx ../src/B0KstMuMuTreeContent.cc ../src/ReadParameters.cc ../src/Utils.cc   -D"ROOFIT" ExtractYield.cc  -lRooFit -lRooFitCore -lFoam  -lMinuit  `root-config --cflags --glibs`

Ie compile the source file as part of the library. And likely unrelated, in general, dependent files should show up in front of dependencies in link lines. Does that help?

Axel

Hi Axel,
unfortunately it didn’t work. Here is wha I got:

iHulk:plugins dinardo$ clang++ -ansi -pedantic -Wall -Wextra -m64 -O3 -o ExtractYield -I ../interface ../src/B0KstMuMuSingleCandTreeContent.cc RooAngleSPdf.cxx ../src/B0KstMuMuTreeContent.cc ../src/ReadParameters.cc ../src/Utils.cc -D"ROOFIT" ExtractYield.cc -lRooFit -lRooFitCore -lFoam -lMinuitroot-config --cflags --glibsUndefined symbols for architecture x86_64: "RooAngleSPdf::Class()", referenced from: RooAngleSPdf::IsA() const in RooAngleSPdf-a4e45b.o RooAngleSPdf::ShowMembers(TMemberInspector&) const in RooAngleSPdf-a4e45b.o non-virtual thunk to RooAngleSPdf::IsA() const in RooAngleSPdf-a4e45b.o non-virtual thunk to RooAngleSPdf::ShowMembers(TMemberInspector&) const in RooAngleSPdf-a4e45b.o "RooAngleSPdf::Streamer(TBuffer&)", referenced from: vtable for RooAngleSPdf in RooAngleSPdf-a4e45b.o "ROOT::GenerateInitInstance(RooAngleSPdf const*)", referenced from: __GLOBAL__sub_I_RooAngleSPdf.cxx in RooAngleSPdf-a4e45b.o "non-virtual thunk to RooAngleSPdf::Streamer(TBuffer&)", referenced from: vtable for RooAngleSPdf in RooAngleSPdf-a4e45b.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

Cheers,

  • Mauro.

Hi Mauro,

Ouch - sorry, you are right, this is missing the dictionary that we delete after linking the ACLiC library. So you’ll indeed need to link against RooAngleSPdf_cxx.so:

clang++  -ansi -pedantic -Wall -Wextra -m64 -O3 -o ExtractYield -I ../interface ../src/B0KstMuMuSingleCandTreeContent.cc ../src/B0KstMuMuTreeContent.cc ../src/ReadParameters.cc ../src/Utils.cc   -D"ROOFIT" ExtractYield.cc RooAngleSPdf_cxx.so -lRooFit -lRooFitCore -lFoam  -lMinuit  `root-config --cflags --glibs`

Then you run it with

LD_LIBRARY_PATH=:$LD_LIBRARY_PATH ./ExtractYield

But it might be easier to just generate that dictionary using an explicit call to rootcling and link that dictionary source file into your binary:

// LinkDef.h
#pragma link C++ class RooAngleSPdf+;
rootcling -f RooAngleSPdf_dict.cxx -c RooAngleSPdf.h LinkDef.h
clang++  -ansi -pedantic -Wall -Wextra -m64 -O3 -o ExtractYield -I ../interface ../src/B0KstMuMuSingleCandTreeContent.cc RooAngleSPdf.cxx RooAngleSPdf_dict.cxx ../src/B0KstMuMuTreeContent.cc ../src/ReadParameters.cc ../src/Utils.cc   -D"ROOFIT" ExtractYield.cc  -lRooFit -lRooFitCore -lFoam  -lMinuit  `root-config --cflags --glibs`

Cheers, Axel.

Many thanks Axel,
it worked !

Actually related to this I have one more question:
the library that I generate are actually generated from this piece of code:

AnglesPDF = RooClassFactory::makePdfInstance("AngleS",myString.str().c_str(),RooArgSet(*VarsAng,*VarsPoly));

Then I would like to call that very same library on anther program and I would like to use the same calling sequence, which is: (string, string, RooArgSet(...))
But if I do this I get the following error message:

clang++ -ansi -pedantic -Wall -Wextra -m64 -O3 -o ExtractYieldroot-config --cflags --glibs-lMinuit -lRooFit -lRooFitCore -lFoam -I ../interface ../src/B0KstMuMuSingleCandTreeContent.cc ../src/B0KstMuMuTreeContent.cc ../src/ReadParameters.cc ../src/Utils.cc RooAngleSPdf.cxx -D"ROOFIT" ExtractYield.cc ExtractYield.cc:947:23: error: no matching constructor for initialization of 'RooAngleSPdf' AnglesPDF = new RooAngleSPdf("AngleS","AngleS",RooArgSet(*VarsAng,*VarsPoly)); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ./RooAngleSPdf.h:24:3: note: candidate constructor not viable: requires at most 2 arguments, but 3 were provided RooAngleSPdf(const RooAngleSPdf& other, const char* name=0) ; ^ ./RooAngleSPdf.h:18:3: note: candidate constructor not viable: requires 0 arguments, but 3 were provided RooAngleSPdf() {} ; ^ ./RooAngleSPdf.h:19:3: note: candidate constructor not viable: requires 6 arguments, but 3 were provided RooAngleSPdf(const char *name, const char *title, ^ 1 error generated. make: *** [ExtractYield] Error 1

It’s like the generated code does not understand RooArgSet, is there a way to avoid this ?

Many thanks again for your support.

  • Mauro.

That’s indeed strange. Let’s see whether @moneta knows?

Dear Axel.
I was wondering whether you had any news about this.

Many thanks,

  • Mauro.

Hi Mauro,

We’ll have to wait for @moneta’s reply; I expect him back from his trip on Monday.

Axel.

Hi Alex,
forgive me if I bother you again on this matter.
Are there any news ?

Many thanks and kind regards,

  • Mauro.

Hi Mauro,

We need the response by @Lorenzo_Moneta or @moneta (he seems to be using two user names these days). He gets notified by mentioning him; let’s hope he finds the time to reply. Please keep pinging and mentioning him until he replies.

Axel.

Hi,

Probably the generated code misses a constructor. Have you tried adding it by hand ?

Lorenzo

Hi Lorenzo,
I’m not sure I know how to do it.

I’m attaching the generated code.
Do I simply need to add the lines:
RooAngleSPdf(const char *name, const char *title, const RooArgSet&);
in RooAngleSPdf.h
and
Roo_AnglesPDFPdf(const char *name, const char *title, const RooArgSet&);
in Roo_AnglesPDFPdf.h ?

Many thanks for your support.
Kind regards,

  • Mauro.

Roo_AnglesPDFPdf.cxx (2.2 KB)
Roo_AnglesPDFPdf.h (1.4 KB)
RooAngleSPdf.h (2.4 KB)
RooAngleSPdf.cxx (5.3 KB)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.