Problem loading library on Mac

Dear MacRooters

I am attaching a short demo library, called libCSMathUtils, which
I have created from a much more complex library libStatUtils.

Sorrowly, for an unknown reason root crashes when trying to load
the library libCSMathUtils.so. As you can see from the following
output, loading my large library libStatUtils.so is ok, but
loading the new short library libCSMathUtils.so is not possible:

Christian-Stratowas-Computer:~/ROOT/rootcode/StatUtils cs$ root


  •                                     *
    
  •    W E L C O M E  to  R O O T       *
    
  •                                     *
    
  • Version 4.01/01 23 July 2004 *
  •                                     *
    
  • You are welcome to visit our Web site *
  •      [root.cern.ch](http://root.cern.ch)            *
    
  •                                     *
    

FreeType Engine v2.1.3 used to render TrueType fonts.
Compiled for macosx with thread support.

CINT/ROOT C/C++ Interpreter version 5.15.138, May 23 2004
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0] gSystem->Load(“libStatUtils.so”)
(int)0
root [1] gSystem->Load(“libCSMathUtils.so”)

*** Break *** segmentation violation
Root > dyld: /Users/cs/ROOT/root/bin/root.exe dead lock (dyld operation attempted in a thread already doing a dyld operation)
Christian-Stratowas-Computer:~/ROOT/rootcode/StatUtils cs$

Interestingly, once again this seems to be a Mac-specific problem.
Do you have any idea why root crahses when trying to load this libary?

Best regards
Christian
mathutils.tar.gz (3.37 KB)

Hi Christian,

there is something wrong with the way you link the bundle. Just use the same what we use in $ROOTSYS/test/Makefile.arch. With this diff to your Makefile4CSMathUtils the loading of the shared library works fine:

— /Users/rdm/a/mathutils/Makefile4CSMathUtils Sun Aug 8 18:52:52 2004
+++ Makefile4CSMathUtils Tue Aug 17 12:57:11 2004
@@ -44,7 +44,7 @@
CXX = c++
CXXFLAGS = -O -pipe -Wall
LD = c++
-LDFLAGS = -O -Xlinker -bind_at_load -flat_namespace
+LDFLAGS = -O -bind_at_load -flat_namespace

The SOFLAGS will be used to create the .dylib; the .so will

be created separately

DllSuf = dylib
@@ -76,7 +76,7 @@
ifeq ($(ARCH),macosx)

We need to make both the .dylib and the .so

            $(LD) $(SOFLAGS) $^ $(OutPutOpt) $@
  •           $(LD) -bundle -undefined suppress -Wl,-x $(LDFLAGS) $^ \
    
  •           $(LD) -bundle -undefined suppress $(LDFLAGS) $^ \
                 $(OutPutOpt) $(subst .$(DllSuf),.so,$@)
    

else
$(LD) $(SOFLAGS) $(LDFLAGS) $^ $(OutPutOpt) $@

Note, on 10.3 you can replace “suppress” with “dynamic_lookup”.

Cheers, Fons.

Dear Fons

Thank you very much for pointing me to the changes in the makefile,
now everything works fine.
Interestingly, I do not experience this problem when compiling my other
libraries, although I used one of these makefiles as template.

Best regards
Christian