Segmentation violation at startup in Mac OsX 10.3

Hello,

I was using the example program on how to compile and link a root application on my Mac G4 running Os X 10.3. At startup the program creates a segmentation violation in GetMacropath(). The main program is as follows:

//----------------------------------------------------------------------
// this creates a segmentation violation on Mac Os X 10.3.1
//
#include “TROOT.h”
#include “TRint.h”

int Error; // left undefined by Motif

extern void InitGui() ; // initializer for GUI needed for interactive interface

VoidFuncPtr_t initfuncs[] = {InitGui, NULL};

// initialize the ROOT system
TROOT root(“Rint”, “The ROOT interactive Interface”, initfuncs );

int main(int argc, char **argv)
{
// create the interactive interface

TRint *theApp = new TRint(“ROOT example”, &argc, argv, NULL, 0);

// Run the interactive interface
theApp->Run();
return(0);
}

However if I move the “TROOT …” object declaration into the main body everything runs. I know that there has to be an issue with scope but I do not understand what is happpening.

The following however does also works:

//----------------------------------------------------------------------
// this seems to work but what about the root system initialization
//
#include <iostream.h>
#include “TROOT.h”
#include “TRint.h”

   int main(int argc, char **argv)
   {
      TRint *theApp = new TRint("ROOT example", &argc, argv);
  
      // Init Intrinsics, build all windows, and enter event loop
      theApp->Run();

      return(0);
   }

All of the above examples run fine on Linux using either REDHAT or SUSE.
Could some of you please help me understand what is going on and what is needed ?

Thanks for your help.

kind regards

Werner

Hi,

The MacOS library loaded is quite different from the linux library loader. We just added the proper work-around for yet another quirk.
Anyway, your last solution (which works for you) is currently the recommended way of coding for both linux and MacOS (i.e. you do NOT need to instantiate a TROOT object).

Cheers,
Philippe