RE: Boost libraries and ROOT

From: Philippe Canal <pcanal_at_fnal.gov>
Date: Wed, 16 Apr 2008 17:21:20 -0500


Hi Augusto,

If you do not need the I/O, use:

    class OptimalCuts{
    public :

#ifndef __CINT__

    boost::tuples::tuple<int, double> T;
#endif

    };

#ifdef __MAKECINT__
#pragma link C++ class OptimalCuts;
#endif

if you do need the I/O, you will need to add a ClassDef (because you are hiding one data member from CINT):

    class OptimalCuts{
    public :

#ifndef __CINT__

    boost::tuples::tuple<int, double> T;
#endif

        ClassDef(OptimalCuts,1);
    };

Cheers,
Philippe.

-----Original Message-----
From: Antonio Augusto Alves Junior [mailto:aalvesju_at_cern.ch] Sent: Wednesday, April 16, 2008 1:01 PM
To: Philippe Canal
Cc: krlynch_at_bu.edu; augalves_at_cbpf.br; 'ROOT Talk' Subject: Re: [ROOT] Boost libraries and ROOT

Hello Philipe,

This was the output when I tried your suggestion:

    root [0] .L boost_test.h++
    Info in <TUnixSystem::ACLiC>: creating shared library     /media/usbdisk/Analysis/B_2_X_b_Dst/script/./boost_test_h.so     Fatal: sizeof(::OptimalCuts) == sizeof(::ROOT::Shadow::OptimalCuts)     violated at line 60 of
    `/media/usbdisk/Analysis/B_2_X_b_Dst/script/./fileWwCCjn.cxx'     aborting
    Using host libthread_db library "/lib/tls/i686/cmov/libthread_db.so.1".     Attaching to program: /proc/25157/exe, process 25157     [Thread debugging using libthread_db enabled]     [New Thread -1224894784 (LWP 25157)]     0xffffe410 in __kernel_vsyscall ()
#1 0xb7093933 in waitpid () from /lib/tls/i686/cmov/libc.so.6
#2 0xb703d3c9 in strtold_l () from /lib/tls/i686/cmov/libc.so.6
#3 0xb71427dd in system () from /lib/tls/i686/cmov/libpthread.so.0
#4 0xb7b1e9d5 in TUnixSystem::Exec () from /opt/root/lib/libCore.so
#5 0xb7b264f9 in TUnixSystem::StackTrace () from
    /opt/root/lib/libCore.so
#6 0xb7a793ab in DefaultErrorHandler () from /opt/root/lib/libCore.so
#7 0xb7a78e57 in ErrorHandler () from /opt/root/lib/libCore.so
#8 0xb7a79080 in Fatal () from /opt/root/lib/libCore.so
#9 0xb5df19a0 in ROOT::GenerateInitInstanceLocal () from
    /media/usbdisk/Analysis/B_2_X_b_Dst/script/./boost_test_h.so
#10 0xb5df2117 in __static_initialization_and_destruction_0 ()
    from /media/usbdisk/Analysis/B_2_X_b_Dst/script/./boost_test_h.so
#11 0xb5df24b5 in __do_global_ctors_aux () from
    /media/usbdisk/Analysis/B_2_X_b_Dst/script/./boost_test_h.so
#12 0xb5df14d9 in _init () from

    /media/usbdisk/Analysis/B_2_X_b_Dst/script/./boost_test_h.so

#13 0xb7ff12ab in _dl_rtld_di_serinfo () from /lib/ld-linux.so.2
#14 0xb7ff135d in _dl_rtld_di_serinfo () from /lib/ld-linux.so.2
#15 0xb7105f40 in getutmpx () from /lib/tls/i686/cmov/libc.so.6
#16 0xb7ff1106 in _dl_rtld_di_serinfo () from /lib/ld-linux.so.2
#17 0xb7106938 in _dl_open () from /lib/tls/i686/cmov/libc.so.6
#18 0xb724c808 in dlmopen () from /lib/tls/i686/cmov/libdl.so.2
#19 0xb7ff1106 in _dl_rtld_di_serinfo () from /lib/ld-linux.so.2
#20 0xb724c2bb in dlerror () from /lib/tls/i686/cmov/libdl.so.2
#21 0xb724c86e in dlopen () from /lib/tls/i686/cmov/libdl.so.2
#22 0xb7536572 in G__dlopen () from /opt/root/lib/libCint.so
#23 0xb7538757 in G__shl_load () from /opt/root/lib/libCint.so
#24 0xb74d0430 in G__loadfile () from /opt/root/lib/libCint.so
#25 0xb7af5bb5 in TCint::Load () from /opt/root/lib/libCore.so
#26 0xb7aba815 in TSystem::Load () from /opt/root/lib/libCore.so
#27 0xb7b1ec09 in TUnixSystem::Load () from /opt/root/lib/libCore.so
#28 0xb7abffc9 in TSystem::CompileMacro () from /opt/root/lib/libCore.so
#29 0xb7af3f41 in ScriptCompiler () from /opt/root/lib/libCore.so
#30 0xb74d0806 in G__loadfile () from /opt/root/lib/libCint.so
#31 0xb750a5ad in G__reloadfile () from /opt/root/lib/libCint.so
#32 0xb750ecc2 in G__process_cmd () from /opt/root/lib/libCint.so
#33 0xb7af5f54 in TCint::ProcessLine () from /opt/root/lib/libCore.so
#34 0xb7a5fa30 in TApplication::ProcessLine () from
    /opt/root/lib/libCore.so
#35 0xb72701e2 in TRint::HandleTermInput () from
    /opt/root/lib/libRint.so
#36 0xb726f807 in TTermInputHandler::Notify () from
    /opt/root/lib/libRint.so
#37 0xb7271c88 in TTermInputHandler::ReadNotify () from
    /opt/root/lib/libRint.so
#38 0xb7b248a1 in TUnixSystem::CheckDescriptors () from
    /opt/root/lib/libCore.so
#39 0xb7b24fbe in TUnixSystem::DispatchOneEvent () from
    /opt/root/lib/libCore.so
#40 0xb7ab5575 in TSystem::InnerLoop () from /opt/root/lib/libCore.so
#41 0xb7ab8b37 in TSystem::Run () from /opt/root/lib/libCore.so
#42 0xb7a5e80a in TApplication::Run () from /opt/root/lib/libCore.so
#43 0xb7270a82 in TRint::Run () from /opt/root/lib/libRint.so
#44 0x08048d13 in main ()

The file boost_test.h is

#include <TROOT.h>
#ifndef __CINT__
#include <boost/tuple/tuple.hpp>
#include <boost/tuple/tuple_comparison.hpp>
#include <boost/tuple/tuple_io.hpp>
#endif

    class OptimalCuts{

    public :

#ifndef __CINT__

    boost::tuples::tuple<int, double> T;
#endif

    };

Regards
Augusto

Philippe Canal escreveu:

> Hi,
>
> Just a general comment :)
>
>   
>> You could modify all the headers and source files for 
>> the Boost libraries you want to use to include the relevant CINT magic 
>> (ClassDef/ClassImp and LinkDef.h files) and generate all the 
>> dictionaries, and then load them up. 
>>     
>
> ClassDef/ClassImp are no longer required to be able to store your object
in
> ROOT file.  You _just_ need a dictionary for the class your want to 
> persist (and all the type of their data members).
>
> Now the hard part is that the CINT parser fails on the boost headers.
> Your best option is usually to hide the boost header file from CINT
> #ifndef __CINT__
>     #include <boost/tuple/tuple.hpp>
>     #include <boost/tuple/tuple_comparison.hpp>
>     #include <boost/tuple/tuple_io.hpp>
> #else
> ... place here revelant forward declaration ....
> #endif
>
> and possibly
>
>     class OptimalCuts{
>        
>     public :
> #ifndef __CINT__
>         boost::tuples::tuple<int, double>T;
> #endif
>
>
> Cheers,
> Philippe.
>
> -----Original Message-----
> From: owner-roottalk_at_root.cern.ch [mailto:owner-roottalk_at_root.cern.ch] On
> Behalf Of Kevin Lynch
> Sent: Wednesday, April 16, 2008 10:52 AM
> To: aalvesju_at_cern.ch; augalves_at_cbpf.br
> Cc: ROOT Talk
> Subject: Re: [ROOT] Boost libraries and ROOT
>
> Antonio Augusto Alves Junior wrote:
>   
>> Hello all,
>>
>> Please, can someone to give some example of usage of the Boost Libraries 
>> with ROOT?
>>
>> regards
>> Augusto
>>
>>     
>
> It's not clear what you are asking for.  If you want to use Boost 
> libraries and the Root libraries in compiled code, you won't have any 
> issues.  I do this all the time ... mostly I use stuff that ended up in 
> TR1 (smart_ptr, tuple, bind, function, etc), but I've also been known to 
> use multi_index, numeric_cast, random, and a few others.  It all works 
> just fine.
>
> If you want to use some specific Boost library as interpreted code, then 
> you will likely be in for a long, tough slog to get it working.  Boost 
> makes EXTREMELY heavy use of advanced template features, as well as lots 
> of config headers and #ifdef'd workarounds for various compilers and STL 
> implementations.  You could modify all the headers and source files for 
> the Boost libraries you want to use to include the relevant CINT magic 
> (ClassDef/ClassImp and LinkDef.h files) and generate all the 
> dictionaries, and then load them up.  You'll have to do all this work if 
> you want to persist Boost objects to TTrees/TFiles, since you need the 
> dictionary in this case.
>
> Personally, I've never bothered with all that ... if the project is 
> complicated enough that I need Boost, I'm going the compiled route 
> anyway.  And I just accept that I'm too lazy to put any Boost objects in 
> TTrees or TFiles  :-)
>
> Finally, a few years back, someone posted a message to roottalk about 
> efforts to Rootify the Boost smart pointers .... I think it was called 
> "ROOST".  I haven't heard anything more since then, but perhaps there's 
> been some more progress.
>
>   

-- 

?"O mais corrente neste mundo, nestes tempos em que às cegas vamos
tropeçando, é esbarrarmos, ao virar a esquina mais próxima, com homens e
mulheres na maturidade da existência e da prosperidade, que, tendo sido aos
dezoito anos briosos revolucionários decididos a arrasar o sistema dos pais
e pôr no seu lugar o paraíso, enfim, da fraternidade, se encontram agora,
com firmeza pelo menos igual, repoltreados em convicções e práticas que,
depois de haverem passado por qualquer das muitas versões do conservadorismo
moderado, acabaram por desembocar no mais desbocado e reaccionário egoísmo.
Em palavras não tão cerimoniosas, estes homens e estas mulheres, diante do
espelho da sua vida, cospem todos os dias na cara do que foram o escarro do
que são."

José Saramago, em Ensaio sobre a lucidez

=============================================

A. Augusto Alves Jr.

CBPF - Centro Brasileiro de Pesquisas Físicas
Rua Dr. Xavier Sigaud 150 – URCA
CEP 22290-180
Rio de Janeiro, RJ, Brazil.

Tel: (55)(21) 2141-7329
Fax: (55)(21) 2141-7556
Received on Thu Apr 17 2008 - 00:21:41 CEST

This archive was generated by hypermail 2.2.0 : Thu Apr 17 2008 - 17:50:01 CEST