Mac OS X and root

Hi Rooters,

I have been having a problem compiling and running programs on Mac OS 10.3.3 using root 3.10.02-14 download and compiled using fink.  I suspect my problems are specific to my installation,  but since I haven't done anything custom,  I hope maybe you will be able to help me.  I can successfully compile the following program:

#include <TCanvas.h>
#include <TApplication.h>

void main(int argc, char **argv)
TApplication myapp(“application”, &argc, argv);
TCanvas c1;

Simple, right? I compile it with the following commands:

~> g++ -ggdb root-config --cflags -I/Users/waldman/Src/include -c
~> g++ -ggdb root-config --libs testint.o -o testint

with no problem. When I run it however, I get:

~> ./testint
dyld: ./testint multiple definitions of symbol __ZN7TCanvas15SetDoubleBufferEi
/sw/lib/root/ definition of __ZN7TCanvas15SetDoubleBufferEi
/sw/lib/root/libGpad.3.dylib(TCanvas.o) definition of __ZN7TCanvas15SetDoubleBufferEi
Trace/BPT trap

If I compile the code commenting out the TApplication line, it works fine, same if I comment out TCanvas. The error seems to be that TApplication links to the library .so and TCanvas.o links to the library .dylib (or something). Can anyone tell me how to fix this?

Thanks very much for your help,

sam waldman

root-config --libs
root-config --glibs


Thanks for the quick reply Rene. Unfortunately, replacing ‘–libs’ with ‘–glibs’ in the linking step did not change the situation.

I also tried adding the flag ‘–noldflags’ to no effect.

Is there any way to see what libraries a program is linking to?

sam waldman


otool -L bin/root.exe

Thanks Eddy,

As might have been expected, "otool -L " only printed the shared .dylib files, which look fine. At some point it seems to be referencing both the .dylib and the .so file and they collide ungracefully. Is there a way to force linking to one or the other (on Mac OSX -shared or -static has no effect)?