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

From: Stephen Sanders (ssanders@ku.edu)
Date: Fri Sep 06 2002 - 15:41:07 MEST


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