RE: [ROOT] Trouble with user libraries under Mac OSX (Darwin)

From: Philippe Canal (pcanal@fnal.gov)
Date: Sat Sep 07 2002 - 01:05:14 MEST


Hi,

I am not sure whether it is revelant or not but in $ROOTSYS/test/Makefile we
use the flag '-bundle' to create the .so file.

You should try to build the Event example and load libEvent to see if it has
the same problem (it it has not the same problem ... then you know what to
do :) ).

Cheers,
Philippe

-----Original Message-----
From: owner-roottalk@pcroot.cern.ch
[mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Stephen Sanders
Sent: Friday, September 06, 2002 9:56 AM
To: Rene Brun
Cc: Damir Buskulic; fujiik@jlcuxf.kek.jp; gmieg@SLAC.stanford.edu;
roottalk
Subject: Re: [ROOT] Trouble with user libraries under Mac OSX (Darwin)


Hi Rene,
Thanks.  Yes, the classes do have the ClassDef stuff:
-------------------------------
#foo.h:
#ifndef FOO
#define FOO

#ifndef ROOT_TObject
#include "TObject.h"
#endif

class Foo : public TObject
{
public:
   Foo();
   Foo(const Char_t * Name, const Char_t * Title);
   virtual ~Foo();
   ClassDef(Foo,0)
     };

#endif
-----------------------------------------------
#foo.cxx:
#ifndef FOO
#include "foo.h"
#endif
#include <iostream.h>
ClassImp(Foo)

Foo::Foo()
{
   //Default constructor.
}

Foo::Foo(const Char_t *name, const Char_t *title):TObject()
{
   cout<<name<<endl;
}
Foo::~Foo()
{
}
On Friday, September 6, 2002, at 09:43 AM, Rene Brun wrote:

> Hi Stephen,
>
> I assume that all your classes (eg Foo) have a ClassDef in the header
> file.
> I cc your mail to the two Darwin experts Keisuke Fujii and George M.
> Irwin
>
> Rene Brun
>
> On Fri, 6 Sep 2002, Stephen Sanders wrote:
>
>> Hi Rene,
>> I believe I am doing this step correctly.  Or, at least, what I am
>> doing
>> works under
>> linux.  For the user class I have
>> --------------------------------------------------
>> rootcint -f foodict.cxx -c -p -O -pipe -fPIC -I/usr/local/include/root
>> -I/usr/X11R6/include -I/usr/X11R6/include/X11 -DDARWIN
>> -I/usr/local/include/brat foo.h fooInclude.h fooLinkDef.h
>>
>> c++ -DPACKAGE=\"foo\" -DVERSION=\"1.0\" -DONL_unix=1 -I. -I. -O -pipe
>> -fPIC -I/usr/local/include/root -I/usr/X11R6/include
>> -I/usr/X11R6/include/X11 -DDARWIN -I/usr/local/include/brat -ldl -c
>> foodict.cxx -Wp,-MD,.deps/foodict.TPlo  -fno-common -DPIC -o foodict.lo
>>
>> c++ -dynamiclib -flat_namespace -undefined suppress -o
>> .libs/libfoo.0.0.0.dylib  foo.lo foodict.lo  -ldl -ldl -lm -lc
>> -install_name  /Users/sanders/lib/foo/libfoo.0.dylib
>> -compatibility_version 1 -current_version 1.0
>> --------------------------------------------------------
>> (I just noticed this was not in the make.log file that I posted.  I had
>> previously created the dictionary file.)
>>
>> Then, for the main TRint derived class:
>>
>> ----------------------------------------------------------------
>> rootcint -f BrRintDict.cxx -c -O -pipe -fPIC -I/usr/local/include/root
>> -I/usr/X11R6/include -I/usr/X11R6/include/X11 -DDARWIN
>> -I/usr/local/include/brat BrRint.h
>>
>> c++ -ldl -o .libs/bratroot -Xlinker -bind_at_load -L/usr/local/lib/root
>> -lCore -lCint -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript
>> -lMatrix -lPhysics -lEG -lMySQL -lm -ldl -L/usr/local/lib -lBratDataAbc
>> -lBratDataParams -lBratModuleAbc -lBratModuleUtil -lBratManager
>> -lBratUtil -lBratDb -lBratDb -lBratDataCalib -lBratDataCentrality
>> -lBratDataGeant -lBratDataParams -lBratDataPid -lBratDataRaw
>> -lBratDataRdo -lBratDataTrack -lBratDataVertex -lBratModuleCalib
>> -lBratModuleCent -lBratModuleSimul -lBratModuleVisual -lBratModuleIO
>> -lBratModulePid -lBratModuleRaw -lBratModuleRdo -lBratModuleTrack
>> -lBratModuleVertex -lBratPackages -L/usr/X11R6/lib -lRint -lSM -lICE
>> -lX11 -lXpm BrRintMain.o BrRint.o BrRintDict.o -lRint -L.libs -lfoo
>> -ldl
>> -ldl -lm
>> ---------------------------------------------------------------
>>
>> Above, the new user library is .libs/libfoo.dylib.  I also have linked
>> in the various BRAT libraries (all created with
>> rootcint), however none of the library classes are available unless I
>> add code like:
>>
>> #include "foo.h"
>> Foo foo;
>>
>> in the main program.
>>
>> Any other suggestions??
>>
>> Regards,
>> Steve
>>
>> On Friday, September 6, 2002, at 08:56 AM, Rene Brun wrote:
>>
>>> Hi Stephen,
>>>
>>> If you want to call your BRAT classes interactively from CINT, your
>>> classes must be known to CINT via the dictionary created with
>>> rootcint.
>>> Are you running this step?
>>> See examples in Users Guide and in $ROOTSYS/test/Event
>>>
>>> Rene Brun
>>>
>>> On Fri, 6 Sep 2002, Stephen Sanders wrote:
>>>
>>>> Hi Damir,
>>>> I do successfully generate both the .dylib and .so library files.
>>>> The
>>>> .so files load fine using
>>>> gSystem->Load("xxx") command, and I can successfully link to classes
>>>> in
>>>> the .dylib libraries.
>>>> My problem (I think--since it doesn't work, I'm clearly missing some
>>>> important step!)
>>>> is somehow related to CINT not recognizing the global symbols in the
>>>> .dylib(??) files.
>>>> I can force things to work OK by creating instances of the user
>>>> classes
>>>> in the TRint derived
>>>> main program.  Unfortunate, the BRAT system has hundreds of classes
>>>> and
>>>> so this is clearly not
>>>> a very attractive solution.
>>>>
>>>> Regards,
>>>> Steve
>>>>
>>>> On Friday, September 6, 2002, at 02:18 AM, Damir Buskulic wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> I had the same kind of problems. Apparently, one needs to generate
>>>>> TWO
>>>>> libraries for each one that was generated before. One for the
>>>>> symbols,
>>>>> one for the code.
>>>>>
>>>>> Can someone explain a little better why and how to do it properly ?
>>>>>
>>>>> I'm also still stuck to that kind of problems. ROOT works fine (so
>>>>> the
>>>>> problem seems solved for it) but my code doesn't work, while it does
>>>>> on
>>>>> all other platforms.
>>>>>
>>>>> Cheers
>>>>>
>>>>> Damir
>>>>>
>>>>> Stephen Sanders wrote:
>>>>>> Hi,
>>>>>> I am attempting to port the BRAT program of the BRAHMS
>>>>>> Collaboration at RHIC to Darwin.  The entire BRAT system  builds
>>>>>> fine,
>>>>>> but I'm
>>>>>> having trouble linking in the brat classes with CINT so that they
>>>>>> are available without doing an explicit gSystem->Load().   Instead,
>>>>>> I get errors of the sort shown below. I have set DYLD_LIBRARY_PATH
>>>>>> to
>>>>>> include
>>>>>> the location of my shared libraries.  I am also able to  explicitly
>>>>>> load the user classes.
>>>>>> The root classes can be accessed fine.
>>>>>> The code and appropriately modified build instructions do work on
>>>>>> linux systems.
>>>>>> ----------------
>>>>>> brat [0] Foo * foo = new Foo()    <---ON LINUX SYSTEMS THIS WORKS
>>>>>> Error: Symbol Foo is not defined in current scope
>>>>>> FILE:/var/tmp/tmp.2.012580_cint LINE:1
>>>>>> Error: Symbol Foo is not defined in current scope
>>>>>> FILE:/var/tmp/tmp.2.012635_cint LINE:1
>>>>>> Error: type Foo not defined FILE:/var/tmp/tmp.2.012635_cint LINE:1
>>>>>> Warning: Automatic variable Foo* foo allocated in global scope
>>>>>> FILE:/var/tmp/tmp.2.012635_cint LINE:1
>>>>>> Error: Undeclared variable Foo* foo FILE:/var/tmp/tmp.2.012635_cint
>>>>>> LINE:1
>>>>>> *** Interpreter error recovered ***
>>>>>> brat [1] gSystem->Load("foo")    <----THIS WORKS
>>>>>> (int)0
>>>>>> brat [2] Foo * foo = new Foo("a","a")
>>>>>> a
>>>>>> -------------------------
>>>>>> If I start the TRint derived main program in gdb,
>>>>>> I am able to set breakpoints on the user class Foo,
>>>>>> but autocompletion does not return the argument lists:
>>>>>> [kunuc5:~/Documents/foo] sanders% gdb ~/bin/bratroot
>>>>>> This GDB was configured as "powerpc-apple-macos10".
>>>>>> Reading symbols for shared libraries .. done
>>>>>> (gdb) break main
>>>>>> Breakpoint 1 at 0x2854
>>>>>> (gdb) run
>>>>>> Starting program: /Users/sanders/bin/bratroot
>>>>>> [Switching to process 12624 thread 0x1603]
>>>>>> Reading symbols for shared libraries ................... done
>>>>>> Breakpoint 1, 0x00002868 in main ()
>>>>>> (gdb) break Foo::Foo
>>>>>> Breakpoint 2 at 0x10ce228
>>>>>> (gdb)
>>>>>> ---------------------------------------------------------------
>>>>>> To test the system, I've built a simple library libfoo with a
>>>>>> single
>>>>>> class Foo. This
>>>>>> is linked to a TRint derived class BrRint as shown below: (I've
>>>>>> supplied links to the
>>>>>> actual programs.) Again, I've moved this to a linux system,
>>>>>> commented
>>>>>> out the MODULE
>>>>>> stuff, and everything works as it should.
>>>>>> ----------------------------------------------------------------
>>>>>> AM_CPPFLAGS = -O -pipe -fPIC -I/usr/local/include/root
>>>>>> -I/usr/X11R6/include -I/usr/X11R6/include/X11
>>>>>> ROOTLIBS=-L/usr/local/lib/root -lCore -lCint -lHist -lGraf -lGraf3d
>>>>>> -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lm -ldl
>>>>>> XLIBS= -L/usr/X11R6/lib -lRint -lSM -lICE -lX11 -lXpm
>>>>>> LIBNAME =libfoo.la
>>>>>> MODULE  =foo.la
>>>>>> pkglib_LTLIBRARIES = $(LIBNAME) $(MODULE)
>>>>>> pkginclude_HEADERS = "http://www.phsx.ukans.edu/~sanders/foo/foo.h"
>>>>>> libfoo_la_SOURCES =
>>>>>> "http://www.phsx.ukans.edu/~sanders/foo/foo.cxx"
>>>>>> foodict.cxx
>>>>>> libfoo_la_LDFLAGS = -ldl -lm  -R$(HOME)/Documents/foo/.libs
>>>>>> foo_la_SOURCES = $(libfoo_la_SOURCES)
>>>>>> foo_la_LDFLAGS = -module -Xlinker -bind_at_load $(ROOTLIBS)
>>>>>> -R$(HOME)/Documents/foo/.libs
>>>>>> bin_PROGRAMS        = bratroot
>>>>>> bratroot_LDADD        = -lRint libfoo.la
>>>>>> bratroot_LDFLAGS    = -Xlinker -bind_at_load $(ROOTLIBS) $(XLIBS)
>>>>>> bratroot_SOURCES    =
>>>>>> "http://www.phsx.ukans.edu/~sanders/foo/BrRintMain.cxx"          \
>>>>>>               "http://www.phsx.ukans.edu/~sanders/foo/BrRint.cxx"
>>>>>> "http://www.phsx.ukans.edu/~sanders/foo/BrRint.h"       \
>>>>>>               BrRintDict.h BrRintDict.cxx
>>>>>> CLEANFILES = *Dict.*
>>>>>> %dict.cxx %dict.h:%.h
>>>>>>     rootcint -f $*dict.cxx -c -p $(AM_CPPFLAGS) $< $*Include.h
>>>>>> $*LinkDef.h
>>>>>> %Dict.cxx %Dict.h:%.h
>>>>>>     rootcint -f $*Dict.cxx -c $(AM_CPPFLAGS) $<
>>>>>> ---------------------------------------------------------------------
--------------------------------------------------------------
>>>>>> The resulting  Makefile is:
>>>>>> "http://www.phsx.ukans.edu/~sanders/foo/Makefile"
>>>>>> The log of the make operation is at :
>>>>>> "http://www.phsx.ukans.edu/~sanders/foo/make.log"
>>>>>> Any suggestions?  Has anyone been successful getting someting like
>>>>>> this to work
>>>>>> under Darwin?
>>>>>> Thanks for any help...
>>>>>> Steve
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> =====================================================================
>>>>> | Damir Buskulic                  | Universite de
>>>>> Savoie/LAPP       |
>>>>> |                                 | Chemin de Bellevue, B.P.
>>>>> 110    |
>>>>> | Tel : +33 (0)450091600          | F-74941 Annecy-le-Vieux
>>>>> Cedex   |
>>>>> | e-mail: buskulic@lapp.in2p3.fr  |
>>>>> FRANCE                          |
>>>>> =====================================================================
>>>>> mailto:buskulic@lapp.in2p3.fr
>>>>
>>



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:08 MET