Hello, Thank you for your assistance. I have a problem which has me puzzled. I am using root version 3.05/05 on RedHat 9/i386/gcc-3.2.2. When I compile the sources below and run 'myroot' I am able to access the function in 'my_ns' namespace just fine. If I start up 'myroot' and try to immediately execute 'script.C' I get the following error: root [0] .x script.C Error: say_hello() header declared but not defined FILE:script.C LINE:8 *** Interpreter error recovered *** root [1] my_ns::say_hello() Error: say_hello() header declared but not defined FILE:(tmpfile) LINE:1 *** Interpreter error recovered *** However, if I start 'myroot' and do this instead everything is fine: root[0] my_ns::say_hello() hello root[1] .x script.C hello root[2] my_ns::say_hello() hello I do not understand what is happening here. Below are the relevant files (also a tarball attachment): //---------------------------my_ns.h #ifndef __my_ns__ #define __my_ns__ namespace my_ns { void say_hello(); }; #endif //---------------------------my_ns.C #include <iostream.h> #include "my_ns.h" void my_ns::say_hello() { cout << "hello" << endl; } //---------------------------main.C #include <TROOT.h> #include <TRint.h> int main(int argc, char **argv) { // Create interactive interface TRint *theApp = new TRint("ROOT example", &argc, argv, NULL, 0); // Run interactive interface theApp->Run(); return(0); } //---------------------------my_nsLinkDef.h #ifdef __MAKECINT__ #pragma link off all functions; #pragma link off all globals; #pragma link off all classes; #pragma link C++ nestedclass; #pragma link C++ nestedtypedef; #pragma link C++ namespace my_ns; #pragma link C++ function my_ns::say_hello; #endif //---------------------------script.C { #ifndef __my_ns__ #include "my_ns.h" #endif my_ns::say_hello(); } ##---------------------------Makefile ARCH = $(shell root-config --arch) CXX = ObjSuf = o SrcSuf = cxx ExeSuf = DllSuf = so OutPutOpt = -o # keep whitespace after "-o" ROOTCFLAGS := $(shell root-config --cflags) ROOTLIBS := $(shell root-config --libs) ROOTGLIBS := $(shell root-config --glibs) ifeq ($(ARCH),linux) # Linux with egcs, gcc 2.9x, gcc 3.x (>= RedHat 5.2) CXX = g++ CXXFLAGS = -O -Wall -fPIC LD = g++ LDFLAGS = -O SOFLAGS = -shared endif CXXFLAGS += $(ROOTCFLAGS) -Wno-deprecated LIBS = $(ROOTLIBS) $(SYSLIBS) GLIBS = $(ROOTGLIBS) $(SYSLIBS) ### HDRS = my_ns.h SRCS = main.C my_ns.C OBJS = main.o my_ns.o PROGRAM = myroot DICTHDRS = my_nsDict.h DICTSRCS = my_nsDict.C DICTOBJS = my_nsDict.o all: $(PROGRAM) $(PROGRAM): $(OBJS) $(DICTOBJS) @echo "Linking $(PROGRAM)..." @/bin/rm -f $(PROGRAM) @$(LD) $(LDFLAGS) $(OBJS) $(DICTOBJS) $(ROOTLIBS) -o $(PROGRAM) @chmod 555 $(PROGRAM) @echo "done" ### my_ns.o: my_ns.h my_nsDict.C: my_ns.h @echo "Generating dictionary..." @rootcint my_nsDict.C -c my_ns.h my_nsLinkDef.h @echo "done" Thanks, -- Regards, Micha D. Niskin <mniskin@yahoo.com>
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:11 MET